Artem Novak
Artem Novak

Reputation: 1

Concatenate a csv file in archive

I stumble with a problem.

I need to read a .csv table in an archive without extracting it. When I try to do that, I face metadata bits in the beginning of the file.

➜  dir ls
people-10000.tar.gz

➜  dir zcat people-10000.tar.gz | head -2
**people-10000.csv0000644000000000000000000431074114440102423012217 0ustar  rootrootIndex**,User Id,First Name,Last Name,Sex,Email,Phone,Date of birth,Job Title
1,5f10e9D33fC5f2b,Sara,Mcguire,Female,[email protected],(971)643-6089x9160,1921-08-17,"Editor, commissioning"

Is it possible to do that?

I tried unzip -p, but have nothing.

➜  dir unzip -p people-10000.tar.gz
[people-10000.tar.gz]
  End-of-central-directory signature not found. 

Either this file is not a zipfile, or it constitutes one disk of a multi-part archive. In the latter case the central directory and zipfile comment will be found on the last disk(s) of this archive.

Upvotes: 0

Views: 38

Answers (1)

Barmar
Barmar

Reputation: 781004

Use the --to-stdout (or -O) option to send the extracted file to stdout rather than creating a file.

tar -x -f people-10000.tar.gz --to-stdout -z filename.csv | head -2

Replace filename.csv with the actual name of the CSV file in the archive.

Upvotes: 1

Related Questions