I have the following code to concatenate several csvs in one only separating each one by a blank row in the final csv. But he is only able to catch the first csv without repeating the same action with the rest. Any idea how I could solve it? Thanks in advance.
#!/usr/bin/env python
import pandas as pd
import glob, os
import shutil
#import csv files from folder
path = r'/Users/sonia/Animalsmanage/output'
allFiles = glob.glob(path + "/*.csv")
with open('finaloutput.csv', 'wb') as outfile:
for i, fname in enumerate(allFiles):
with open(fname, 'rb') as infile:
if i != 0:
infile.readline()
outfile.write(bytearray('\n'))
shutil.copyfileobj(infile, outfile)
print(fname + " has been imported.")