Read All Files And Store In One Dataframe Pandas Code Example

Snippet 1

  path = r'C:DRODCL_rawdata_files'                     # use your path
all_files = glob.glob(os.path.join(path, "*.csv"))     # advisable to use os.path.join as this makes concatenation OS independent

df_from_each_file = (pd.read_csv(f) for f in all_files)
concatenated_df   = pd.concat(df_from_each_file, ignore_index=True) 

Copyright © Code Fetcher 2020

 

 

Leave a comment

Your email address will not be published. Required fields are marked *