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
  pandas.to_datetime: Combine data from 2 columns ju21878436312 1 444 Feb-20-2021, 08:25 PM
Last Post: perfringo
  Python PDF merging from an excel pandas for loop siraero 0 810 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 1,026 Jul-24-2020, 01:56 PM
Last Post: onenessboy
  pandas read_csv can't handle missing data mrdominikku 0 676 Jul-09-2020, 12:26 PM
Last Post: mrdominikku
  Pandas data frame creation from Kafka Topic vboppa 0 481 Jul-01-2020, 04:23 PM
Last Post: vboppa
  Generate Test data (.csv) using Pandas Ashley 5 941 Jun-15-2020, 02:51 PM
Last Post: jefsummers
  excel data erase d8a988 1 656 Apr-27-2020, 05:43 PM
Last Post: snippsat
  Read json array data by pandas vipinct 0 631 Apr-13-2020, 02:24 PM
Last Post: vipinct
  add formatted column to pandas data frame alkaline3 0 588 Mar-22-2020, 06:44 PM
Last Post: alkaline3
  Python read Excel cell data validation anantpatil 0 1,510 Jan-31-2020, 04:57 PM
Last Post: anantpatil

Forum Jump:

User Panel Messages

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