Concatenate numbers into a python csv file

Asked

Viewed 50 times

-1

I have a problem with a CSV file, because I have a CSV file with phone numbers, but the number 55 is missing in front of the numbers. how can I is doing this in python.

This is my code

import pandas as pd
xls = pd.ExcelFile('telefones.xlsx')
df = xls.parse(sheetname="teste", index_col=None, na_values=['FONE1'])
colum = df["FONE1"]
colum.to_csv("NumerosBOT.csv", index=False, header=None, sep=',')
print(colum)

Example of the list of CSV numbers

88992146288
84999697743
84999426811
84996022656
84996283916
84996566623
84996014057
84996331151
...
84999964363

And I wanted to leave everyone in this format 55 84 9 99999999

How would that be done?

1 answer

-1


df["FONE1"] = df["FONE1"].apply(lambda x: '{0:5>13}'.format(x))

Browser other questions tagged

You are not signed in. Login or sign up in order to post.