Reputation: 11
My requirement is to save a pandas dataframe as parquet inside a date folder which should be created dynamically if not present. I am having the folder names inside a list(date_folder_list), 'parquet_folder' is an existing folder. The code with which I have tried is given below. Please help -
for x in date_folder_list:
print(x)
dir = os.path.join('parquet_folder/%s' %str(x) + '/')
if not os.path.exists(dir):
reconcilitn_df.to_parquet(os.makedirs(dir)+'/asasass.parquet' ,engine='pyarrow',compression='snappy')
Error I am getting: TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
Upvotes: 0
Views: 756
Reputation: 11
I got the solution.
for x in date_folder_list:
print(x)
dir = os.path.join('parquet/%s' %str(x))
if not os.path.exists(dir):
os.makedirs(dir)
reconcilitn_df.to_parquet('parquet' + '/' + str(x) + '/' + 'Reconciliation.parquet' ,engine='pyarrow',compression='snappy')
else :
reconcilitn_df.to_parquet('parquet' + '/' + str(x) + '/' + 'Reconciliation.parquet' ,engine='pyarrow',compression='snappy')
Upvotes: 1