I would expect the code to merge the output csv files line by line. It will write the first lines one after another, then the second lines one after another.
import numpy as np, pandas as pd, os, glob
path = (r'E:\csvfile')
all_files = glob.glob(path + "/*.csv")
li = []
for filename in all_files:
df = pd.read_csv(filename, index_col=False, header=0)
li.append(df)
frame = pd.concat(li,axis=0,names=None)
frame.to_csv (r'E:\csvfile\exportC.csv', mode = 'w', index=False)
I tried the shorter code with different parameters. >
import pandas as pd, glob
df = pd.concat(map(pd.read_csv, glob.glob(r'E:\csvfile/*.csv')),axis=0)
df.to_csv (r'E:\csvfile\exportC.csv',mode = 'w', index=False)
file1.csv
0, 10,12
0,11,12
1,15,12
file2.csv
0, 2, 1
1,22, 1
3, 11, 1
file3.csv
0, 4, 6
9, 14, 13
5, 6, 2
The expected output.
0, 10,12
0, 2, 1
0, 4, 6
0,11,12
1,22, 1
9, 14, 13
1,15,12
3, 11, 1
5, 6, 2
Thank you from now.
0, 2, 1?