Skip to main content
Question

cannot write headers in csv file


  • Opening Band
  • 19 replies

is there a way to write headers first like the ones in yellow rows in the screenshot before adding the needed columns after in a csv file ?

after the 4th row the data should be displayed as a normal csv file, However i cannot figure out how to write the first 3 rows .

 

10 replies

alex.sanchez
StreamSets Employee
Forum|alt.badge.img
  • StreamSets Employee
  • 73 replies
  • September 14, 2022

@N_ali


Based on how data is structured in a CSV, we understand headers as the very first row, meaning that it contains the column name.

 

I don't think we support adding multiple rows as headers. If you are a customer my recommendation will be to open a feature request


  • Author
  • Opening Band
  • 19 replies
  • September 14, 2022

and if the file was in xlsx format , it’s not supported either ?


alex.sanchez
StreamSets Employee
Forum|alt.badge.img
  • StreamSets Employee
  • 73 replies
  • September 14, 2022

They are technically the same, at the end our records are a map of key values, so we take the header (first row) as keys and then the subsequent rows as values


  • Author
  • Opening Band
  • 19 replies
  • September 14, 2022

Noted.
Thanks.

 


Bikram
Headliner
Forum|alt.badge.img+1
  • Headliner
  • 486 replies
  • September 15, 2022

@N_ali 

If you want to add header , you can try using scripting processor .  


  • Author
  • Opening Band
  • 19 replies
  • September 16, 2022
Bikram wrote:

@N_ali

If you want to add header , you can try using scripting processor .  

Can you please provide me with an example on how to add the above headers to a csv/xlsx file ?


Bikram
Headliner
Forum|alt.badge.img+1
  • Headliner
  • 486 replies
  • September 16, 2022

@N_ali 

I will try to provide the code snippet for that.

Let me clear your need , you need headers columns should be after the data row.

If you can provide me a sample file which you are trying and your expected result then i can help you on that.

 


  • Author
  • Opening Band
  • 19 replies
  • September 16, 2022
Bikram wrote:

@N_ali

I will try to provide the code snippet for that.

Let me clear your need , you need headers columns should be after the data row.

If you can provide me a sample file which you are trying and your expected result then i can help you on that.

 

Here is the scenario:

  1. The origin will be an sftp server , I will take the input csv file and parse its content.
  2. The content is awb number and tracking number , ….. etc.
  3. i want to write this content in another file ( like the one attached ).

The only difference is that i need to write three rows first that are not included in the data ( the first three yellow rows in the attached file) then writing the header row then the actual data as usual  .

 


Bikram
Headliner
Forum|alt.badge.img+1
  • Headliner
  • 486 replies
  • September 18, 2022

@N_ali 

 

Please find attached the pipeline for your case and try it from you and let me know if it helps.

 


Bikram
Headliner
Forum|alt.badge.img+1
  • Headliner
  • 486 replies
  • September 18, 2022

@N_ali

Result based on the input provided bu you. Please change the date format if you need .

 


Reply