Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request: aq.fromCSV2() #160

Closed
dan-reznik opened this issue May 7, 2021 · 3 comments · Fixed by #161
Closed

feature request: aq.fromCSV2() #160

dan-reznik opened this issue May 7, 2021 · 3 comments · Fixed by #161
Labels
enhancement New feature or request

Comments

@dan-reznik
Copy link

dan-reznik commented May 7, 2021

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: ',' });
@jheer jheer added the enhancement New feature or request label May 7, 2021
@jheer jheer closed this as completed in #161 May 9, 2021
@jheer jheer mentioned this issue May 9, 2021
@jheer
Copy link
Member

jheer commented May 9, 2021

This use case is now supported in Arquero v4.5.0, through the addition of the decimal option for fromCSV and loadCSV. I did not end up adding a shortcut from/loadCSV2 method, but hopefully this helps!

@dan-reznik
Copy link
Author

dan-reznik commented May 9, 2021 via email

@jheer
Copy link
Member

jheer commented May 10, 2021

Column rename was already added, use table.rename().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants