Merging multiple CSV files without headers being repeated (using Python)

前端 未结 5 730
长情又很酷
长情又很酷 2020-12-08 01:38

I am a beginner with Python. I have multiple CSV files (more than 10), and all of them have same number of columns. I would like to merge all of them into a single CSV file,

5条回答
  •  隐瞒了意图╮
    2020-12-08 02:11

    If you are on a linux system:

    head -1 director/one_file.csv > output csv   ## writing the header to the final file
    tail -n +2  director/*.csv >> output.csv  ## writing the content of all csv starting with second line into final file
    

提交回复
热议问题