Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

What would be an efficient way to extract only all of the *.csv files (not other files inside) from inside a hundred zip files in a single directory? Then I need to make one large file with each CVS file appended together although stripping off header line 1 from files 2,...,n.

If it works well I would like to use 7-Zip's 7za.exe the command line version or other solutions that are self contained and don't require installation on a WinXP platform. The zips contain other data I don't need.

Simple appending is easy with file1+file2+..., but how about dropping the header?

share|improve this question
add comment

3 Answers 3

Actually, to skip the header in Unix/Linux, you would need the 'tail' command.

You can tell the 'tail' command to skip the first line (the header) by doing the following:

tail -n+2 filename

This will tell tail to start reading from line 2.

To do this on all .csv files in your current directory, and append them together, put the following in a script:

#!/bin/bash

for file in *.csv
do
tail -n+2 $file
done

You can then run this script like ./script.sh>output and the output will be in the file named 'output'.

Unfortunately I do not know if something like tail is available in any capacity on Windows without ports.

share|improve this answer
    
thanks bash and the tail program make it easy on some platforms. –  ExcelCyclist Jan 3 '10 at 0:38
add comment

but how about dropping the header?

With the unix 'head' command (from mingw, opench or a bunch of other utils) you can use "head -n" to show all but the first 'n' lines

share|improve this answer
    
thanks, is that available on windows without a messy cygwin port? –  ExcelCyclist Jan 2 '10 at 23:06
    
You can get it from unxutils.sf.net (among others) –  TML Jan 2 '10 at 23:48
add comment

To my embarrassment the answer on extracting just a particular file type from within a all compressed files in a directory with 7Zip is simply:

7za.exe e *.zip *.csv

Then to combine the files with a batch file (although its disappointing this single line can't be typed in to the command prompt)

[saved as foo.bat for example]
for %%X in (*.csv) do tail -n+2 %%X >> combined.csv
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.