May-05-2021, 03:13 PM
Hello everyone,
I looked everywhere but I can't seem to find a solution to my problem.
I have a text file containing data with decimal type '.'. Using read_csv, I import the data to python. The problem is that when I want to write it to Excel my data get ',' decimal type. I want to keep the '.'.
Does anyone know how to solve the problem ?
Here is the code I used :
6.02382e-009;-0.0157154
0.0252904;0.0352284
Thanks in advance,
Manon
I looked everywhere but I can't seem to find a solution to my problem.
I have a text file containing data with decimal type '.'. Using read_csv, I import the data to python. The problem is that when I want to write it to Excel my data get ',' decimal type. I want to keep the '.'.
Does anyone know how to solve the problem ?
Here is the code I used :
import numpy as np import pandas as pd fileName="exemple.txt" data = pd.read_csv(fileName, sep=";") # on récupère les données des fichiers dans un tableau writer = pd.ExcelWriter(fileName.split('.',2)[0]+'.xlsx',engine='xlsxwriter') data.to_excel(writer,index=False,header=None) # on recopie les tableaux de données dans les fichiers excel writer.save()My text file contains these 2 lines
6.02382e-009;-0.0157154
0.0252904;0.0352284
Thanks in advance,
Manon