How to add headers to a csv file from another file


#1

I was wondering how you could set the header of an csv file using another table as input.
So I have a csv file without headers and I want to add headers to it which I fetch from another file.

Ideal scenario

So I load in the csv
Merge the header value from the other file
Set the headers of the csv file from these headers

Thanks!


#2

@kvbe

I did find this article that may address your situation.

Guy


#3

Thank you very much!
What I ended up doing was the following:

  • Load data without headers
  • Load the header data
  • Change from a column based to a row based list of headers (transposed it)
  • Use merge as new query with the csv data
  • The headers are added as the first line into the csv data
  • promote to header

done,

The power query editor is quite a phenomenal tool if you know all the ins and outs of it!


#4

Hi,
the editor is absolutely great for things like this.
For a dynamic way to normalize column names, i.e. someone decides to change the name(s) or sequence of your headers without telling you, I can recommend the book Collect Combine and Transform Data using Power BI by Gil Raviv.
Paul


#5

Second that! There’s some great things in there. Write a couple of functions you can reuse and save yourself so much time!