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
Cell 1,2 is not a number, and should be converted to a string, not a number.
Possible solution (optional, but very helpful):
The problem comes from default mapper in the csv parser. It check whether datum could be a number with Number(datum).
But Number(' ') returns a number. I think is not the expected case for this conversion.
// csv.jsfunction(datum){if(datum===''){returnnull;}constdatumNumber=Number(datum);// -------> Here !!!if(!Number.isNaN(datumNumber)&&datumNumber!==Infinity){returndatumNumber;}constdt=dateFormats.reduce((matchingDate,currentDateFormat)=>{if(matchingDate){returnmatchingDate;}constdayjsObj=dayjs(datum,currentDateFormat,true);if(dayjsObj.isValid()){returndayjsObj;}returnnull;},null);if(dt){returnnewDate(dt.valueOf());}constspecial=SpecialValues[datum];if(special!==undefined){returnspecial;}returndatum;};
The solution could be trim data before passing it to Number function.
馃悰 Bug Report
When I pass a csv with a cell containing only spaces, it is converted to 0 by
csv.read
.Lib version: 4.4.0
Steps To Reproduce
The expected behaviour:
Cell 1,2 is not a number, and should be converted to a string, not a number.
Possible solution (optional, but very helpful):
The problem comes from default mapper in the csv parser. It check whether datum could be a number with
Number(datum)
.But
Number(' ')
returns a number. I think is not the expected case for this conversion.The solution could be
trim
data before passing it to Number function.Possible hack while it's not merged
It's to pass our own fixed mapper :
The text was updated successfully, but these errors were encountered: