I'm working with csv files because we will have that as a source of truth (I know, not the best way but its what marketing familiar with and no time available to build a CMS)
Anyway, lets say I have an excel file with merged cells as bellow:
Plain csv file looks like:
Main ,MainDescription,Secondry,Code
First,First Description,First Secondry 1,CODE 1
,,First Secondry 2,CODE 2
,,First Secondry 3,CODE 3
,,First Secondry 4,CODE 4
,,First Secondry 5,CODE 5
,,First Secondry 6,CODE 6
,,First Secondry 7,CODE 7
,,First Secondry 8,CODE 8
Second,Second Description,Second Secondry 1,CODE 9
,,Second Secondry 2,CODE 10
,,Second Secondry 3,CODE 11
,,Second Secondry 4,CODE 12
,,Second Secondry 5,CODE 13
,,Second Secondry 6,CODE 14
,,Second Secondry 7,CODE 15
,,Second Secondry 8,CODE 16
Is there any "smart" javascript csv parser I can use? I can write the logic myself, I just hope that there is something out there.
Ideally I would expect this to be parsed as bellow:
[
{
"Main": "First",
"MainDescription": "First Description",
"Secondry": [
"First Secondry 1",
"First Secondry 2",
"First Secondry 3",
"..."
],
"Code": ["Code 1", "...", "Code 8"]
},
{
"Main": "Second",
"MainDescription": "Second Description",
"Secondry": [
"Second Secondry 1",
"Second Secondry 2",
"Second Secondry 3",
"..."
],
"Code": ["Code 9", "...", "Code 16"]
}
]
