Python Forum
how to save to multiple locations during save - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: how to save to multiple locations during save (/thread-40980.html)



how to save to multiple locations during save - cubangt - Oct-23-2023

I have a script with currently outputs a csv for a report.. But now multiple departments want access to the raw data.

I currently have this to_csv line in my script, but would like to be able to save the results to multiple locations for each department that wants the raw data

merged_results.to_csv(parts[0] + '_ip_output_' + dtstring +'.csv',header=False, index=False, quoting=None)
I was thinking of building a list of departments and pathes and then have a for loop for each one in the list, run the above line with the appropriate path.
Is that the most optimal way to handle this.. I mean right now its only 3 different paths along with the original path that its currently saving to, So 4 total places.


RE: how to save to multiple locations during save - deanhystad - Oct-23-2023

Learn to say "No". Put the files in a shared folder and send them a link to the folder. Not only is it easier for you, but it is also a better solution for everyone. If you make a list of departments and directories it is something you'll need to maintain and modify as your user's needs change. If you put the information on a share, your users are free to copy the files anywhere they want, or just use the (readonly) file in the share.