Trying to download the table data of a SQL query into a .csv. When trying this, all data ends up being concatenated into a single (very long) row. How do I re-pivot the data, similar to how its displayed in a Database table?
(I'm a bit of a novice to JS, but happy to learn)
Hey @ThePepijnH, welcome to the community
utils.exportData(formatDataAsArray(line_tems_for_DHL.data), 'data', 'csv')
Worked like a dream! Thank you
One follow-up, how do I get rid of the headers?
You may be able to do this by setting your headers to be the values in your first row. Something like
.shift should do the trick:
_.mapKeys(line_tems_for_DHL.data, value => value.shift())
(this also sneakily removes the first row from the dataset). Does the following give you what you're looking for?
utils.exportData(formatDataAsArray(_.mapKeys(line_tems_for_DHL.data, value => value.shift())), 'data', 'csv')