We receive data in the form of emails containing csvs.
These emails are stored in an s3 bucket and via a python job we read each csv, create a standard dataframe structure, and concatenate all these dataframes into a single frame.
However, there are times in which we don't get the same number of csv's and due to the unique nature of each file, we have to create a separate dataframe for each csv and then concatenate together.
What I'd like to do is make the process more tolerant to the variable number of dataframes that will be created.
Current the code is as follows:
try:
Read CSV
Do stuff to prepare standard dataframe
except:
print('fail')
...numerous try-catch blocks...
frames = [ALL CREATED DATAFRAMES]
result_frame = pandas.concat(frames)
What I need is code that will allow me to get only the dataframe objects that exist and use that as the list for frames.
I tried using dir() and creating a list from the resulting generator object but that is only the string variable name, not the variables themselves.
ideas?