I'm unsure what you're trying to do in your compose, but could you not go from your PowerBI direcly (skipping compose) to "create csv table" and then save the results to sharepoint?
Csv starts with a header row and then continues with data for each line, so out of the box it should do what you need. - The delimiters can be different depending on region (I've seen many csv's (Comma Seperated Values) that are semicolon separated, so that might also be your issue.
Perhaps you should show us a bit of your dataset... as in
Current state => desired state
so that we have an idea of what transformation you want to achieve here, more details please.