Python Forum

Full Version: [Pandas] Write data to Excel with dot decimals
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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 :
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
It is an Excel setting which defines how numbers are shown: with a decimal point or a decimal comma.
It is described here: Change the decimal point to a comma or vice versa.