Remove line breaks in excel with python

Viewed 28

hope someone can help. I've got an excel file with the line breaks in row 3 in name and address columns. Trying to remove them and save file in csv format enter image description here

using the following code:

read_file['name']=(read_file['name'].str.replace(',','').replace('\r','').replace('\n', '').replace('\t', '')) *#remove commas from name column and line breaks*
read_file['Address']=(read_file['Address'].str.replace(',','').replace('\r','').replace('\n', '').replace('\t', '')) *#remove commas from address column*
read_file.to_csv (r"C:register.csv", index = None, header=False)

But the output csv looks like below, part of name and address been shifted to the column 1.



1.0,One Two,    185 CHURCHTOWN ROAD CHURCHTOWN DUBLIN 8 IRELAND,
1.0,"alpha, beta
gamma, delta","GLENARD CROSTHWAITE PARK DUN LAOGHAIRE CO DUBLIN IRELAND
GLENARD CROSTHWAITE PARK DUN LAOGHAIRE CO.DUBLIN IRELAND",

Thanks in advance.

0 Answers
Related