Downloading a table without headers

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?

utils.downloadFile(line_tems_for_DHL.data,'data','.csv')

(I'm a bit of a novice to JS, but happy to learn)

Hey @ThePepijnH, welcome to the community :hugs:

Try this:

utils.exportData(formatDataAsArray(line_tems_for_DHL.data), 'data', 'csv')
1 Like

Worked like a dream! Thank you :slight_smile:

One follow-up, how do I get rid of the headers?

Hey @ThePepijnH!

You may be able to do this by setting your headers to be the values in your first row. Something like _,mapKeys and .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')
1 Like

Thank you :slight_smile: