specify custom Sheet2JSONOpts config per possible header? #2958

Open
opened 2023-06-01 17:43:36 +00:00 by zamazo · 0 comments

I'm processing a csv where the columns values are either all numbers that need to be processed as strings, or dates like '5/21/2023' that need to be processed as dates.

Using the 'raw' option in Sheet2JSONOpts, I can get the numbers to register as strings.
Using the 'dateNF' option, I can get the dates to properly register as dates.

However, cannot get both to work at the same time.

Is it possible to specify multiple Sheet2JSONOpts configs per header, or any other way of doing this?
Would rather not have to do post mapping/converting as each csv is massive.

I know all the possible headers and what type they will be, just not which order they come in and if they will appear at all.

Thanks!

Example:
image

output using 'raw' option:
image
=numbers->string ok, but dates not processed

output using 'dateNF' option:
image
=numbers->numbers and not string, dates are properly processed though

(using: "xlsx": "https://cdn.sheetjs.com/xlsx-0.19.3/xlsx-0.19.3.tgz")

I'm processing a csv where the columns values are either all numbers that need to be processed as strings, or dates like '5/21/2023' that need to be processed as dates. Using the 'raw' option in Sheet2JSONOpts, I can get the numbers to register as strings. Using the 'dateNF' option, I can get the dates to properly register as dates. However, cannot get both to work at the same time. Is it possible to specify multiple Sheet2JSONOpts configs per header, or any other way of doing this? Would rather not have to do post mapping/converting as each csv is massive. I know all the possible headers and what type they will be, just not which order they come in and if they will appear at all. Thanks! Example: ![image](/attachments/be0a9796-d590-4a1b-a0a3-dd913c3776b5) output using 'raw' option: ![image](/attachments/43c3555c-ab64-4b6c-a120-e8a53f57db93) =numbers->string ok, but dates not processed output using 'dateNF' option: ![image](/attachments/c7b832cc-881f-469f-825f-05e900d036b0) =numbers->numbers and not string, dates are properly processed though (using: "xlsx": "https://cdn.sheetjs.com/xlsx-0.19.3/xlsx-0.19.3.tgz")
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sheetjs/sheetjs#2958
No description provided.