Wrongly parsing csv string cell as date
See original GitHub issueWhen reading a CSV string, some fields that should be parsed as strings are parsed as dates.
This happens when the string ends with something that resembles a date.
Use the following snippet to reproduce.
var foo = 'foo,bar\nfoo2,bar2\n"Wololo thing - ends Feb. 15, 2017","Wololo thing - ends Feb. 15, 2017 bar"';
var w = XLSX.read(foo, {type: "string", cellDates: true});
console.log(w.Sheets.Sheet1);
Expected result: the third row contains 2 strings:
{t: "s", v: "Wololo thing - ends Feb. 15, 2017"}
{t: "s", v: "Wololo thing - ends Feb. 15, 2017 bar"}
Actual result: the third row contains
{t: "d", v: Wed Feb 15 2017 00:00:00 GMT-0200 (-02), w: "2/15/17"}
{t: "s", v: "Wololo thing - ends Feb. 15, 2017 bar"}
Issue Analytics
- State:
- Created 6 years ago
- Reactions:8
- Comments:14 (4 by maintainers)
Top Results From Across the Web
Stop Excel from automatically converting certain text values to ...
Open the CSV file as text (notepad); Copy it (ctrl+a, ctrl+c). Paste it in a new excel sheet -it will all paste in...
Read more >Formatting Dates for CSV Imports - Administration - Echo360
Basic steps: select the date column, right-click and select Format Cells, then select Custom and enter yyyy-mm-dd in the text field. Open the...
Read more >Make my Excel parse dates from CSV like everyone else's
What I have discovered: The Excel documentation is misleading, if not wrong. The date format of the cell apparently only serves for display....
Read more >Stop Excel from Converting Text to Number or Date format ...
Option 1: Rename .csv to .txt and then open in Excel. To prevent Excel from automatically changing the data format to number/date format,...
Read more >Date format incorrect on CSV user upload - Zendesk help
When bulk importing users into Zendesk through CSV upload, the dates are formatted incorrectly. Microsoft Excel changes the date format.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m using xlsx.read(foo, { type: ‘string’, raw:true }); and I’m getting the dates in the expected plain text format
This seems crazy to me! Keep it as a string of course!!!
This behavior should be disabled on request. I’m importing a CSV (tried with xls too) to perform corrections and it keeps on converting values like “VIA MARTUCCI 2” to the date “3/2/01”, I tried using
raw: true
but it simply uses the number “36952”. Only with xlsx files it doesn’t convert these values.