0

I want to check if the dataframe created is stored in a location or not. If not I want to create a new df with the same name.

Example:

List of df fromm the location : list = [df1, df2, df3, df4]

to_check = [df4]

for i in list1:
    if to_check in list1:
        read the file_
    else:
        create new df

I want to read the if its there. And create one if it doesn't exists

vidathri
  • 101
  • 1
  • 9

1 Answers1

1
import os
if os.path.exists(f'./{to_check}.csv'):
    pd.read_csv(f'./{to_check}.csv')
rektifyer
  • 51
  • 4