Chuck Chuck - 1 year ago 112
Python Question

how to merge 200 csv files in Python

Guys, I here have 200 separate csv files named from SH (1) to SH (200). I want to merge them into a single csv file. How can I do it?

Answer Source

As ghostdog74 said, but this time with headers:

# first file:
for line in open("sh1.csv"):
# now the rest:    
for num in range(2,201):
    f = open("sh"+str(num)+".csv") # skip the header
    for line in f:
    f.close() # not really needed
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download