Skip to content

feature request: aq.fromCSV2() #160

Closed
@dan-reznik

Description

@dan-reznik

Many non-US csv's use ";" as separators and "," as decimal markers. Call these "type-2" csv's. In R there are two functions: read_csv() for regular US-style, and read_csv2() for type-2.

Currently one needs to do something like the code below in order read type-2 csv (available on Observable here):

parseColon = v => parseFloat(v.replace(",","."));

table = aq.loadCSV('type2.csv', // could be aq.fromCSV() as well
           { delimiter: ";", parse : { col1: parseColon, col2: parseColon } })

so my suggestion is smtg like the above gets wrapped into aq.loadCSV2() and aq.fromCSV2(). It will avoid much rework. Also notice one would not need to list which numeric columns need to be parsed with "parseColon". This logic would be internalized. If a column is deemed numeric, apply the right parsing.

alternatively, you can add "decimal_marker" to the option object in loadCSV() and fromCSV(), defaulting to ".". so the new code would look like

table = aq.loadCSV('type2.csv', // could be aq.fromCSV() as well
           { delimiter: ";", decimal_marker: ',' });

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions