Reputation: 1
I am attempting to read a csv file and then save it in another location.
I have tried importing csv or string. I am realizing it only seems possible using Pandas. I have tried sep = ' ' and sep = '\s+' (this gives error) and I have tried a regex command from an earlier answered post ( I cant remember the exact command). So far sep = '\t' seems like it should work but it is not.
import pandas as pd
readfile = pd.read_csv('C:\\xx\\xx\\xx, xx.csv','rb')
with open('T:\\xx\\xx\\xx.csv','w') as writefile:
readfile.to_csv(writefile, index = False, sep = '\t')
I expect the data to be exported in an excel file in multiple columns. I however, get all the data in 1 column when I open the excel file. If I print the variable readfile, using print(readfile) I get the following:
25 1 1 9 \t \t T w o - W i r e O h m s \t 1 ...
26 1 2 0 \t \t T w o - W i r e O h m s \t 1 ...
27 S c a n C o n t r o l : \t S t a r t A ...
28 S c a n \t T i m e \t 1 0 1 ( O H M ) \t A ...
29 1 \t 7 / 2 4 / 2 0 1 9 1 3 : 1 3 : 3 5 : 3 ...
.. ...
72 4 4 \t 7 / 2 4 / 2 0 1 9 1 3 : 2 0 : 4 5 : ...
Upvotes: 0
Views: 1399
Reputation: 463
In Excel, select Data-> Text to Columns and then set the delimiter to tabs
Upvotes: 1