Dates and certain values getting converted, raw and cellDate not helping #749
Labels
No Label
DBF
Dates
Defined Names
Features
Formula
HTML
Images
Infrastructure
Integration
International
ODS
Operations
Performance
PivotTables
Pro
Protection
Read Bug
SSF
SYLK
Style
Write Bug
good first issue
No Milestone
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: sheetjs/sheetjs#749
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hi,
Thanks for the library, its great. But as of late i've been having some issues.
As usual i have looked through all issues and documentation.
I have a CSV with cells that have different date formats, negative numbers, positive numbers, decimals, text etc..
If i use
raw: true
, then some of the dates get converted into a number which I don't want, i want the dates to stay as is. If i useCellDates: true
, some dates get converted, some don't and the format they get converted to is different to how it is in the csv (csv: dd/mm/yyyy, sheetJS Obj: mm/dd/yy
). With or withoutraw
, I have a few negative numbers which get converted.. so for example: -0.08 gets converted to 36739.If i load the CSV into sublime text the values in the CSV match that of excel, the actual values. But SheetJS is converting these.
Raw
converts them, not havingraw
converts them, dates are converted either way and i'm trying to find a way to get the information as it is without any changing.Is this possible?
I have noticed something strange.. In excel i did a 'save as' still in csv format and the issue is resolved.
That doesnt help me as the CSV file I have is exported from another system and I cant get clients to save as every time.
Like i said in sublime text the values show correct, in excel they show correct but creating json gives a different result.
@GreggOD We're looking into this. There's quite a bit of guesswork involved for CSV and it's not always correct.
Plaintext formats that mix content and presentation (CSV / HTML / PRN) are not great formats. On the writing side it is extremely easy to generate something that looks correct, but there's no "correct" way to read data back so we have to "guess" what type of data is contained in each cell. And that guess is currently too aggressive in parsing dates and not aggressive enough in interpreting number values.
To contrast with other formats, native Excel files separate the content (numeric values are always stored as IEEE754 doubles in XLSB and XLS, for example) from the presentation (separate number format codes), so there is little guesswork involved.
@SheetJSDev ahhh ok. Shame guys, sounds like a tough gig for you.
What i noticed was my 1 csv sheet has all values in double quotes: "value", the other had some values without double quotes and some with.. This seemed to be tripping things up.
So when I used
cellText: true
andraw: true
, all the values that had double quotes were then again wrapped in quotes so they came out like this:""Header"",""value""
but at least the cells were unaltered. I guessraw
andcellDates
probably don't matter if you usecellText
?For anyone else with this issue:
These are my reader options:
I then did this to remove each rows double quotes:
I guess I could have stringified the whole file object and done the regex:
app.file = JSON.parse( JSON.stringify(app.file).replace( /\\\"/g, '' ) );