Created
April 8, 2020 16:35
-
-
Save lakshay-arora/342b7fcba8d69d96f37080ae253b5e05 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create a list to store the dataframes | |
dataframe_list = [] | |
# iterate through folder 1 to 34 | |
for folder in range(1, 35): | |
# try we are able to read the file | |
try : | |
### notice that for folder i, we have file name "region_i" | |
### create the file name | |
file_name = 'region_' + str(folder) + '.csv' | |
### read the file if possible | |
data = pd.read_csv('dataset/'+ str(folder) +'/' +file_name) | |
dataframe_list.append(data) | |
# if any error occurs, skip this step and continue reading other files. | |
except FileNotFoundError: | |
print('File not found!!', file_name) | |
# If any other error occurs, print the file name | |
except Exception: | |
print('Another Error!!', file_name) | |
continue |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment