I have a .csv file with 100 rows of data displayed like this
“Jim 1234”
“Sam 1235”
“Mary 1236”
“John 1237”
What I’m trying to achieve is splitting the numbers from the names into 2 columns in python
edit*
Using,
import pandas as pd df = pd.read_csv('test.csv', sep='s+') df.to_csv('result.csv', index=False)
I managed to get it to display like this in excel
However, the numbers still do not show up in column B as I expected.
Advertisement
Answer
Your data have only one column and a tab delimiter:
pd.read_csv('test.csv', quoting=1, header=None, squeeze=True) .str.split('t', expand=True) .to_csv('result.csv', index=False, header=False)