I am trying to create a python function which help to do following Tasks
- Read .csv files from a folder
- Create different data-frame for each file with (dataframe name should be same as file name)
- Create list of all created data frame and assign same to a variable(variable name is name of folder)
Below is the Code I am trying:
import pandas as pd
import os
def read_folder():
path = input('Please provide path name to read:')
for file in range(1000):
if os.path.exists(path + '/' + str(file) + '.csv'):
file = pd.read_csv(path + '/' + str(file) + '.csv')
folderpath = (os.path.split(path)[1])
temp = []
temp.append(file)
print(temp)
else:
print('No file at given location')
I have also tried different answers available in this site but somehow most of those have different goal. I am running above code for it doesn't work for me.
Did I miss something on the above code?