Error "The CSV file format for _____ is invalid. Line 3 contains more values than the header line."

Hi All,

Can someone point me out how to solve this error while reading CSV file

Read CSV: The CSV file format for _____ is invalid. Line 3 contains more values than the header line.

Below is the example format of the CSV
image

Hi,

Can you try the following step?

First, read csv file as string using ReadTextFile activity (Let’s sa strCsv)
Then remove the first 2 line using the following expression.

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

Finally, convert it to DataTable usgin GenrateDataTable with CSV option

Regards,

You need to skip the first 2 lines and start reading from the 3rd.
You could create a local copy of the CSV file, delete the first 2 lines, then read it again (so that the header is on the 1st line).

Alternatively, you can use the Excel Read Range activity and specify the correct range (starting from the 3rd row).

You can check on the forum for similar posts. :slight_smile:

How do I ignore the first row of a CSV when using Read CSV - Help - UiPath Community Forum

Read csv from fourth row - Help / Forum - UiPath Community Forum

your 2 first lines are white or just one cell, then the header is: or white or one cell, so the rest of table is bigger than header

it gives me an error

image

Hi,

Can you check if the first argument of Regex.Replace is same variable of output of ReadTextFile?

Regards,