Make second row of datatable to be the header

I converted a .csv file into datatable and want to set the second row as my header. But the program throws an error which i am not able to resolve. I can’t upload .csv file so I have converted to xlsx.
Please help.

set second row as header.xaml (8.2 KB) P-2160-003-A.xlsx (11.0 KB)

1 Like


Can you try the following steps?

  1. Read whole data as string using Read Text File Activity.
  2. Remove 1st row using Regex.Replace method (or Replace activity) (Pattern should be "^.*\n" )
  3. Convert string to datatable using Generate DataTable activity.

Hope the following image helps you.



doing it with Excel:

doing it with csv:

First Assign: File.ReadAllLines(CSVFilePath).ToList()
Second Assign: CSVLines.Skip(1).ToList
Config Generate DataTable:

find starter help here:
Vernon_Shen.xaml (6.8 KB)
CSV as Zip (865 Bytes)


Thank @ppr and @Yoichi, I will try and feedback.

Based on both your methods, it seems like I have to remove the first line of the CSV. Am I right?

If I want to keep the first line, I have to remove it, manipulate the data and then insert in back again. Is that right?

Yes, we can do it like this

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.