def StatsUnion(filename1, filename2, filename3):
with open(filename1) as inputfile, open(filename3, 'w', newline='') as outputfile:
writer = csv.writer(outputfile)
for row in csv.reader(inputfile):
if any(field.strip() for field in row):
writer.writerow(row)
with open(filename2) as inputfile, open(filename3, 'a', newline='') as outputfile:
writer = csv.writer(outputfile)
for row in csv.reader(inputfile):
if any(field.strip() for field in row):
writer.writerow(row)
Here my function that works for merging 2 CSV file in a new one. Is there a way to make it for more CSV files in an easy way ? Columns would be always the same
lower_case_with_underscoresstyle for function and variable names.