Coder Social home page Coder Social logo

CSV : decimal separator about pyexcel HOT 5 CLOSED

doudz avatar doudz commented on June 7, 2024
CSV : decimal separator

from pyexcel.

Comments (5)

jgonggrijp avatar jgonggrijp commented on June 7, 2024 1

May I request that this ticket be reopened. pyexcel is actually in control here, in the sense that it is doing an extra number coercion step beyond what the builtin csv module is doing. That extra step is preventing people like me and @doudz, who need to work with decimal commas, from reading the numbers correctly. Consider the following CSV:

"2023-07-29";"0,02"

If I do this:

import csv

with open('the-above-file.csv') as my_file:
    print(next(csv.reader(my_file, delimiter=';')))

I get ('2023-07-29', '0,02') as output. The second field is not interpreted, I can do a string replacement to replace the decimal comma by a decimal point.

However, if I do this:

import pyexcel

print(pyexcel.get_array(file_name='the-above-file.csv', delimiter=';')[0])

I get ['2023-07-29', 2]. The second field has already been interpreted and the position of the decimal comma has been lost.

I can understand if you cannot or don't want to support decimal commas, but at least please give us a way to switch off automatic number coercion so we can address it ourselves. As it currently is, I have to revert to the standard csv module.

from pyexcel.

jgonggrijp avatar jgonggrijp commented on June 7, 2024 1

@CodeWithOz I didn't use iget_records. I'm fortunate enough that I only need to work with small spreadsheets.

from pyexcel.

chfw avatar chfw commented on June 7, 2024

that has to be with your data presentation. pyexcel or csv module are not in control.

from pyexcel.

doudz avatar doudz commented on June 7, 2024

Yes, I have converted float to string and then replace dot by comma

from pyexcel.

CodeWithOz avatar CodeWithOz commented on June 7, 2024

@jgonggrijp were you using pyexcel's iget_records method? If so, how did you replace its functionalty with the standard csv module? Asking because I'm using iget_records for processing large files without loading them all into memory, so I need a solution that won't blow out my memory if I switch away from pyexcel.

from pyexcel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.