I have this code to export my dataframe to a csv with a timestamp:
import datetime
dt_string = datetime.now().strftime("%Y.%m.%d_%H%M%S")
df.to_csv('history/df' + dt_string + '.csv', sep=',', encoding='utf-8')
and this code to add it to a zip file:
import zipfile
with zipfile.ZipFile('history/df.zip', 'a') as myzip:
myzip.write('history/df' + dt_string + '.csv')
I can then delete the *.csv after.
Is there any way I can skip all the middle steps and directly export a dataframe as a csv file into an existing zip file?
Ideally with a file structure something like this.
df.zip
>df_2020.02.28_144535.csv
>df_2020.02.28_152010.csv
>df_2020.02.28_171942.csv
>df_2020.02.28_221014.csv
I hope that's clear enough. Thanks