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
Yoichi
(Yoichi)
October 30, 2020, 10:10am
2
Hi,
Can you try the following steps?
Read whole data as string using Read Text File Activity.
Remove 1st row using Regex.Replace method (or Replace activity) (Pattern should be "^.*\n"
)
Convert string to datatable using Generate DataTable activity.
Hope the following image helps you.
Regards,
6 Likes
ppr
(Peter Preuss)
October 30, 2020, 10:20am
3
@VERNON_SHEN
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
P-2160-003-A.zip (865 Bytes)
3 Likes
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?
ppr
(Peter Preuss)
October 30, 2020, 3:19pm
5
Yes, we can do it like this
system
(system)
Closed
November 2, 2020, 3:19pm
6
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.