The CSV file format for <file> is invalid

we have not launched a new excel package recently, so i doubt that you got updated today but still, can you send me a screenshot like this:

1 Like

I’ve created a brand new script and any .CSV I get the same error on any I try to open. The new workflow only has the Read CSV activity.

Just wondering but are you using “file.csv” or “file.CSV”. The lower case has caused me problems in the past and now I try to only use upper case in both the file name and the activity.

Don’t know if that will help.

Thanks.

I had .csv, but changed it to .CSV. Worth a try. This has been working for a very long time, just started last night to give this error:

Weird. And you saved the file again to the new extension rather than rename the file?

There was also a post on this forum with same issue and he resolved it by rebooting. haha, worth a try right?

I would also make sure the file is delimitted by comma (Open in Notepad) and doesn’t have any zeroes in blank fields and few other things. You could do some research online too.

Hopefully you get that figured out with UiPath.
Their helpdesk is here https://uipath.zendesk.com/hc/en-us

If it comes down to it you could always use Read Text File, then either process it in string format or Write CSV then read it back again to datatable, but probably not the most ideal.

1 Like

Strange thing is that this was working since the initial build of the workflow. And, our other workflows use the same approach. The file is a simple comma-delimited text file. This is crazy. I’ll try another reboot.

I’ve indirectly managed to solve the problem. I opened the .CSV file in Excel and saved to a new name (as CSV type). I have no idea why UiPath was unhappy with the previous file. Nothing had changed in that file - timestamps were same. I had tried to do it saving over the previous file name but that never worked. Saving to a new file, renaming to the old name worked.

can i have the sample csv file? the broken one

I’m sorry, two problems. 1) I deleted the old versions, and 2) I could not send it to you without changing the values in the as it had sensitive information, which would alter the aspect of sending you the bad file.

the only activity done in that csv file is reading the content? are there any other users interacting with that file?
have you opened it in notepad++ for example, to modify data in it? maybe changed the encoding ?

Only one process/user accessing at a time. I tried notepad++, wordpad and others. Also tried all types of encoding.

I got the same error but I fixed it by changing the delimitator from comma to semicolon.
image

8 Likes

Hi,

I am getting the same error as mentioned above with CSV files.Do we have any fix for this?

Can you share the csv file? How is it generated?

I had a similar issue and found out that UiPath isn’t able to read the CSV-file if there’s an empty line at the beginning. The read CSV activity works fine after removing the empty lines.

empty_line

We will investigate

1 Like

Using Read Text File for an String output, and then Generate Data Table on that output with semicolon as ColumnSeparators worked good for me.
Only thing is that the generated data table did not reflect the completely empty lines from csv file.

I’m having the same error and reading the file as txt and then Generate Data Table is too slow since there are many rows to process… Is there another solution for this? Thanks

Like ddeneau, I was trying to read a CSV file that was generated the error “The CSV file format for filename is invalid”. I tried “Read CSV” and '“Read Text”, but neither function worked.

I have a workaround, but I don’t have a solution.

I discovered that if I opened the CSV file in Excel and the save it as a new CSV file, then I could read the file. Here’s why…

I compared the original CSV file to the new CSV file in Notepad (the files look identical in Excel) and I discovered the encapsulation for these files was different.

The original file looked like this:
“Field 1 has no comma”,“Field 2 has no comma”,“Field 3, has a comma”,“Field 4 has no comma”, etc.

The new file looked like this:
Field 1 has no comma,Field 2 has no comma,“Field 3, has a comma”,Field 4 has no comma, etc.

In other words, the file I could not read was encapsulating all fields in double-quotes. The file that I could read was only encapsulating fields where the value included a comma in double-quotes.

Note: Encapsulation and encoding are not the same thing! Changing the encoding is not the answer to this problem.

Does anyone know of a way for UiPath to read a CSV file where all fields are encapsulated in double-quotes?

The workaround of re-saving the files in a CSV format defeats the purpose of automating this task, so it’s not a viable workaround for me.

Incidentally, CSV files with all fields encapsulated in double-quotes are very common, so I hope UiPath has a solution (or develops a solution) for this issue.

Thank you for anyone who can provide a solution!