The CSV file format for <file> is invalid

Clayton, you were right! The file was not being generated correctly!

However, it wasn’t due to all field values being encapsulated by double quotes. It was due to one of the values in a single field having quotes within that field. The application typically encodes all quotes like this —> & quot ; (with no spaces between those characters).

Somehow, this value slipped through the cracks. Once I logged into the web application and updated the data it was able to export a CSV file that UiPath could read.

So, the good news is, UiPath can read CSV files in which all fields have double-quotes encapsulating text!

Thanks for the quick response! Sorry for making the incorrect assumption that it was an issue with UiPath.

I had the same issue, and tried using Excel to save as to look what is different about the new file…

In my case, the original file came with n-columns like:

column 1;column 2; column3

but data came like:

data column1; data column 2; data column 3;

and the last “;”, was like uipath were expecting a column that was not declared at the begining, I noted because the Excel saved file didn’t include a last “;”, so I just edited the file with notepad++ adding a new column to the header and it worked, so the problem was de original csv file

Hope be helpful

Regards,
GSP

1 Like

Is any solution to this problem ? Facing same issue

Please let me know asap if anyone have tried something workaround for this. reading text file did not worked for me

Thanks,
Mohini Nemade

1 Like

@ddeneau @mohininemade301094

I simply fixed it by assigning Output.
Control + K to create a variable, and I named it any. The reading happened normally.
Caution with the Delimiter. Normally is comma, but can change.

Thanks!..seems to be wierd…but tried…didnt work:-(

I am facing the same problem. Has anyone come up with a solution?

1 Like

My csv file is delimited by semicolon and fix, that adding a semicolon in the end of the firts line

I have had the same problem, I have to extract certain data from many curriculum vitae in web format. I need that data in three formats: xlsx, csv and txt. Occasionally someone introduces a character like “(”, “%”, “$” or similar. When extracting the data to xlsx and from there to csv there is no problem but when I pass it from csv to txt, UiPath returns the error “The CSV file format is invalid.” There would be two solutions: the first would be to pass an “IF activity” to remove those special characters and the second would be to prohibit those characters at source but this will not be in my hand since it is another company the that carries it;)

Hi @H_Zulu

Could you maybe provide a sample file that is causing the issue. I’d try to reproduce it and then register it as a bug in our system if it does :slight_smile:

Ok, I can’t upload the xaml because I’m a new user, I send you a screenshot. You will have to create an excel file with the name test.xlsx to reproduce the error. In a cell enter a comma and it will process the file to CSV but not to TXT. Thanks

The output of the “Read Range” is a datatable called excelDT which is the input of the “write CSV”.
The output of the “Read CSV” is a datatable called csvDT which is the input of the “OUTPUT DATA TABLE” whose output is the varCsvAsString variable that we use as input in the “Write Text file”.
Sorry for the tongue twister.

Hi @H_Zulu

Could you paste here a sample line of your Excel data? :slight_smile:

I tried to reproduce and noticed something. Why do you read the CSV file and then save it to a text file if you can output the datatable right away and save it to a file?
By default, it will separate it with commas:

For reference, I am using the 2.7.2 version of the UiPath.Excel.Activities package.

Hi @loginerror
The reason to use the CSV to convert it into txt having the DT ready is because the tool that uses the department that needs the data in a txt file has to have the delimiter like PIPE “|” and from OUTPUT or from WRITE TEXT FILE I can’t use it.
I show you an example line (the data are fictitious, normally people don’t write a comma between first and last name but it happens)
image

I also encountered this error using the Read CSV activity. I figured out that my file only has 2 fields on lines 1-4 (the document’s header) while the actual table having 7 columns is written on line 5 up to the last line. I tried deleting the first four lines, leaving only the actual datatable, and the run was successful.

I guess this error appears if you have fewer fields on your header (line 1) than the rest of the file. You might also want to check if all your lines have the same number of fields.

Possible work-around is to

  1. read the file as text
  2. Remove the lines that makes the number of fields inconsistent
  3. Convert the text as datatable either by a.) saving it first as csv and use Read CSV activity or b.) use loops to store each field on the cells of a datatable or c.) use split functions to get specific data on each row. The practical choice would depend on how you would need the data from the file.

Hope this helps.

For me it worked when I changed to Tab. Thanks a lot

I also had the same issue,
but after changing Delimiattor on Read CSV activity my code is working fine

Any solution to this?

Just got the same problem and fixed it. Just updated excel activities package now which then gave more detailed error. At my case it stated that this csv file have more details in eleventh row of the file than the first line (headers). By checking file and deleting those details, everything went fine.

Thanks, helped me a lot.

Also facing same issue nit able to read csv read above mwtod and try but did not work. Can anyone send xmal file… thanks