Python Forum

Full Version: how to save to multiple locations during save
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
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.