I have a folder in my directory which consists of CSV files. I am using Python and generating some CSV files with data through code dynamically. So everytime when the code runs, CSV files will be created in a folder called csv (for example).
I had scheduled this code to run for every 10 days through cron jobs. So for every 10 days the Python code runs and the CSV files will be created in the csv folder.
Now i want to compress the csv folder with zip and want to send an email with this ZIP file as an attachment.
- Is it possible to compress a folder with CSV files tot the ZIP format?
- After compressing, is it possible to send this compressed ZIP as an email attachement?
If so, can anyone please let me know how to do it Is it possible to do the above stuff through Python? Or we can do this through linux commands?
The simple way would be to run a separate cron job to do the zipping and emailing:
zip -r - csv | uuencode | mail -s "csv zips for $(date)" foo@bar.comIf you run the above as a cron job, make sure that you
cdinto the parent directory first. So ifcsvis/home/foo/csv:cd /home/foo && zip -r csv | uuencode | mail -s "csv zips for $(date)" foo@bar.com