You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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: ',' });
The text was updated successfully, but these errors were encountered:
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!
Jeff, flattered you did this! Thanks! My students are having a ball w
Arquero! Any chance the request for column rename can be included as well?
that is pretty crucial.
Dan
On Sun, May 9, 2021 at 7:08 PM Jeffrey Heer ***@***.***> wrote:
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!
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#160 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AD32VFR7BGBNNT5FP4KXFCDTM4BXFANCNFSM44KOWOWA>
.
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):
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
The text was updated successfully, but these errors were encountered: