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
The onParseEntry callback function provides plenty of scope to parse entries to
numerical values, Booleans, convert special cases to other values, etc, but
since it always skips a value when a hook to boolean false, you cannot use it
to handle values that parse to boolean false.
Repro example:
var ParseBool = function (value)
{
if (value == "true")
{
return true;
}
else if (value == "false")
{
return false;
}
else
{
return value;
}
}
var contentCSV = "index,isAwesome\n0,true\n,1,false";
var data = $csv.toObjects (contentCSV, {onParseValue : ParseBool});
This will produce a JSON array with two objects of structure { index :
someIntString, isAwesome : someBool }, one which looks like {index : "0",
isAwesome : true } and one that looks like {index : "1", isAwesome : 0 }.
It would be better is the library used undefined to decide when to skip a
value, or simply didn't have a skip-value check when parsing values, as it
makes less sense to skip parsing specific values than it does to skip entire
entries, for example. I've commented out the if hook !=== false line at 474 of
the source (in the endOfValue function of parseEntry) and it gives no
detrimental effects.
Original issue reported on code.google.com by [email protected] on 11 Aug 2014 at 2:06
The text was updated successfully, but these errors were encountered:
Original issue reported on code.google.com by
[email protected]
on 11 Aug 2014 at 2:06The text was updated successfully, but these errors were encountered: