Python Forum
[Pandas] Write data to Excel with dot decimals
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pandas] Write data to Excel with dot decimals
#1
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
Reply
#2
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Write from dictionary to excel divon 0 68 Sep-27-2022, 05:06 AM
Last Post: divon
  Split excel file and write output at specific row and set sheet position DSCA 0 628 May-12-2022, 07:29 PM
Last Post: DSCA
Thumbs Up can't access data from URL in pandas/jupyter notebook aaanoushka 1 797 Feb-13-2022, 01:19 PM
Last Post: jefsummers
  Help with poorly formatted excel data armitron121 1 932 Jan-13-2022, 07:31 AM
Last Post: paul18fr
Question Sorting data with pandas TheZaind 4 1,300 Nov-22-2021, 07:33 PM
Last Post: aserian
  Exporting data frame to excel dyerlee91 0 966 Oct-05-2021, 11:34 AM
Last Post: dyerlee91
  Pandas Data frame column condition check based on length of the value aditi06 1 1,575 Jul-28-2021, 11:08 AM
Last Post: jefsummers
  pandas.to_datetime: Combine data from 2 columns ju21878436312 1 1,656 Feb-20-2021, 08:25 PM
Last Post: perfringo
  Python PDF merging from an excel pandas for loop siraero 0 1,517 Aug-16-2020, 09:34 AM
Last Post: siraero
  How to compare two json and write to third json differences with pandas and numpy onenessboy 0 3,267 Jul-24-2020, 01:56 PM
Last Post: onenessboy

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020