Jan-07-2021, 01:53 AM
OK,
I found the solution myself, I don't know if this is clean, proper but it works.
Never touch a working script...
hahaha
ok,
I am sure this will help others.
I found the solution myself, I don't know if this is clean, proper but it works.
Never touch a working script...
hahaha
ok,
I am sure this will help others.
import pandas as pd import glob path = r"path\to\my\folder\*.csv" df2 = pd.DataFrame(columns=['Name','Reading', 'Office','Phone','address' ]) csvfiles = [] for file in glob.glob(path): csvfiles.append(file) # print(file) for csvnub in csvfiles: df=pd.read_csv(csvnub) count_row = df.shape[0] print(count_row) df2=pd.concat([df, df2]) df2.sort_values(by=['Name']) df2.drop_duplicates(keep='first', inplace=True) df2.to_csv("InfosTotal.csv", index=True, encoding="utf_8_sig")