Unable to read CSV file

Hi

I want to read the CSV file. I’m using the READ CSV activity but getting error

Error: “Read CSV: The CSV file format for Communication File\data.csv is invalid. Line 2 contains more values than the header line.”

I’ve attached the csv file below.

Hi,

Can you try as the following?

First, read csv file as string using ReadTextFile activity.
Next remove the first line of the string using the following expression.

strCsv = System.Text.RegularExpressions.Regex.Replace(strCsv,"^.*\n","")

Finally, convert it to DataTable using GenerateDataTable activity with CSV option.

Regards,

1 Like

You can also try below steps

  1. Read csv file as string using Read Text File activity.

  2. Generate datatable from the string using Generate DataTable activity with csv parse option and Use Column Header option.

1 Like

I’ve tried this scenario and its working. In this case no need to use assign activity. Directly convert sting to DataTable variable easily.

Thank you!!

1 Like

its working fine.

Thank you!!

1 Like

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