papa parse - to dynamic table
papa parse - to dynamic table
I'm thinking I can't be the first person to want to do this, but I can't find any posts regarding this...
I am using papa parse to bring text file contents into a sql table/dataTable. I love using this as there is no need to upload the actual text file to the server. However, my issue is that the text file structure is able to change as new columns are added. I have a "crosswalk" table linking column headers to another table (and eventually I unpivot the table in a sql stored procedure). However, whenever a new column is added to the text file I need to re-publish my dataTable with the new column to receive the data.
Question: Is there a way to use PapaParse to dynamically create the columns of a dataTable using the headers of the text file as column names and then populate the dataTables rows with the text file data? (then I can worry later about how to get that data to an unpivot process using my crosswalk table)
or, is there something better than papaparse to use for this need?
This question has an accepted answers - jump to answer
Answers
I think I am on to something, but I am getting an error:
In the console log for data[0] (line 22 above), returns something like:
ah, turns out it was hanging up on the columns, not the data. this seems to be working:
now i just need to figure out how to get these dynamic columns over to my sql unpivot stored proc
in case this helps anyone else, here is how I ended up doing the 'unpivot'
there may have been an easier way using classes to split the data out, but this was all I could figure out
Nice, thanks for posting back,
Colin