2021年4月28日星期三

How to add new file to dataframe

I have a folder where CSV files are stored, AT certain interval a new CSV file(SAME FORMAT) is added to the folder.

I need to detect the new file and add the contents to data frame.

My current code reads all CSV files at once and stores in dataframe , But Dataframe should get updated with the contents of new CSV when a new file(CSV) is added to the folder.

import os  import glob  import pandas as pd  os.chdir(r"C:\Users\XXXX\CSVFILES")    extension = 'csv'  all_filenames = [i for i in glob.glob('*.{}'.format(extension))]    #combine all files in the list  df = pd.concat([pd.read_csv(f) for f in all_filenames ])  
https://stackoverflow.com/questions/67310068/how-to-add-new-file-to-dataframe April 29, 2021 at 09:58AM

没有评论:

发表评论