5

I have a simple batch script that copies multiple csv files into one csv and i can't seem to find a way to do the same thing in powershell at a comparable speed. In batch it goes like this:

Copy "*.csv" Merged.csv

It copies roughly 20 3MB csv's to one file in mere seconds.

In powershell the closest i've come is:

dir *.csv | Import-Csv | Export-Csv allsites.csv -NoTypeInformation

This method takes a really long time. Is there a method in powershell would be comparable in speed to the DOS command above?

1 Answer 1

5

This should do the same as you DOS command.

(get-content *.csv) | set-content Merged.csv

But either one are going to end up with extra header rows in the result file.

1
  • Is there a way to do this that only copies the top 100 rows of the CSV's?
    – Gixxy22
    Sep 1, 2014 at 18:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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