I have to merge multiple CSV files with same headers. I have to keep the header of the first file and remove headers of all the other files and merge them and create one mas
Just as a side note for everyone who uses the accepted solution of this thread (like me as well :)) - be careful that this code will fail if the header contains new lines, i.e., something like
column1,"column\nwith\new line",column2
value1,value2,value3
...
In this case, only the part column1,"column
will be considered as the header and the rest of the header will be considered a normal row (which will completely break your final CSV). If you have a header with a new line inside, the only solution I can think about is to use a "full-fledged" csv reader library which will be able to correctly read the header.
But despite of this minor issue, the line above saved me from a lot of head ache. :D