How two merge several .csv files horizontally with python?

后端 未结 6 585
渐次进展
渐次进展 2021-01-14 16:11

I\'ve several .csv files (~10) and need to merge them together into a single file horizontally. Each file has the same number of rows (~300) and 4 header lines which are not

6条回答
  •  没有蜡笔的小新
    2021-01-14 16:27

    You learn by doing (and trying, even). So, I'll just give you a few hints. Use the following functions:

    • To open a file: open()
    • To read all the lines in a file: IOBase.readlines()
    • To split a string according to a series of splitting tokents: str.split()

    If you really don't know what to do, I recommend you read the tutorial and Dive Into Python 3. (Depending on how much Python you know, you'll either have to read through the first few chapters or cut straight to the file IO chapters.)

提交回复
热议问题