How to add header to Append CSV Activity

Hi All,

I get the queue item from orchestrator and i want save that in the excel file , i use the Append CSV Activity , i get all value except header

how can i add the header ?

Thanks

You can use Write CSV

Assign a new Datatable object to MyDt.Clone, where MyDt is your first datatable. If you write the new datatable object to a file, it’ll just append the header.

However, this is only if you have some reason to not write all of the data as in ImPratham45’s solution.

when i use that it is give me first row only so i use the append

Thanks

If there is already data and u want to write another below that with headers
Then u can read that data then use Write Range with range
“A”+(DT.Rows.Count+2).ToString

hi @Anthony_Humphries

sorry i do not understand

and the @ImPratham45 becouse Solution when i use that only i get the fist row for that i use the append

hi @ImPratham45 no i get the data from queue

When u use append range you are getting value and when u use Write then u are getting only one row?

If using Write CSV is only writing the first row, then at the time you’re writing the data there is only one record in the datatable you’re writing to the file. Are you writing the range while iterating through a loop? If so, write the range after the loop.

yes but when i use append i get value without header .

Process.xaml (9.9 KB)

could you please see my workflow so you can understand what i do

Thanks

HI @coder

You’re asking that if there’s any way to add headers with append csv. So let me tell you no, append is to only append data without headers.
As you’re getting queue items 1 by 1, you’re using item.SpecificContent(“Header1”).ToString, So you don’t want to find out headers (you know it), you just want to add headers in data… right? correct me if I’m wrong.

In this case you can simply WriteCell all headers and then use append csv.
OR
Use build data table activity and mention headers as you know, and then after getting values using Add DataRow you can able to add data in data table and then write range whole data with Headers.

1 Like

The process you posted creates a datatable with one row in it. To write the entire table, use Write CSV, and not Append CSV.

Yes there is only one row is added so Write range will give only one row with headers if u tick include headers

@Anthony_Humphries

no i use the Re Framework

GetTransactionData.xaml (8.2 KB)

sorry but i confused , i do not know if my solution is correct or no but it is work fine only i need add header

Please upload a zipped copy of the project if you can. GetTransactionData.xaml is just one of the components of the REFramework.

Hi @samir

yes i getting queue items 1 by 1 , and i use build data table activity

could you please check my workflow

Thanks

@Anthony_Humphries i uploaded

Performer_Under.zip (997.9 KB)

@Anthony_Humphries i create other project for dispatcher and this for performer

Try this. I’ve added a section to the Init state where a blank table is written to the CSV. The rest of your code is the same. This way, you’ll be appending the data for each transaction after the header has already been added at the initialization step. I put this under the “First Run” section of the Init state so it wouldn’t rewrite the header on a retry.

AmazonSite_Performer_Under.zip (998,3 Ko)

2 Likes

Thank you i will try that now