Reputation: 147
My code prints output like the title states, (0.25, 0.78, 0.33, ...) and so on.
I have an excel sheet in which I need to move that result into consecutive cells, left to right. It's an extremely tedious process.
When I try and simply copy-paste the Python output, and paste into excel, everything gets bundled into one cell, with the commas etc.
I'd like to "paste" them directly into separate cells. Is there a way of doing this?
Thanks.
Upvotes: 1
Views: 722
Reputation: 2818
Excel will interpret tabs as a 'new column' marker when pasting. If you're using the csv
module, you can create your writer like this:
mywriter = csv.writer(csvfile, delimiter='\t')
If you can't replace your commas with tabs for whatever reason, there's a wizard to reformat things after pasting.
One way to start the wizard is to paste your data into one cell, select that cell, and then from the "Data" tab, select "Text to Columns", and it will start a wizard to convert the data into separate columns. Choose 'Delimited', press 'Next', and make sure 'Comma' is selected on the next screen before pressing 'Finish'
Alternatively, after you've pasted it should show a 'Ctrl' highlight in the bottom right of the newly pasted text. Click that, it will let you start the Text Import Wizard, which has the same options as above.
Upvotes: 2