How to merge vertically several csv files in Python? -
i need merge vertically data several csv spreadsheets in python. structure identical, need put 1 table's data on top of following because months on annual survey. tried several methods found googling can't find way simple as:
import csv spreadsheets1 = open('0113_re_fscom.csv','r') spreadsheets2 = open('0213_re_fscom.csv','r') spreadsheets = spreadsheets1 + spreadsheets2 spreadsheet csvfile: sales = csv.reader(csvfile) row in sales: print row
thanks in advance. r.
looks forgot iterate on files. try code:
import csv spreadsheet_filenames = [ '0113_re_fscom.csv', '0213_re_fscom.csv', ] filename in spreadsheet_filenames: open(filename, 'r') csvfile: sales = csv.reader(csvfile) row in sales: print row
Comments
Post a Comment