Error Concatenate CSV Loop

Hi there, I am trying to concatenate several CSV files but it seems that the source files have a format problem. I manage to read the file proper format, but by clicking “Autodetect format”, which is not possible while running a loop

The files are uploaded here and also attaching the workflow. CSV Loops.knwf (18.7 KB)

Thank you

Well the problem is that your files aren’t all formatted the same.

Most of them use the semicolon delimiter, but there’s at least one that uses a comma.

That would need to be fixed in the source files.

2 Likes

Yeah, two of the files are delimited by a comma and the other by a semicolon.

Thank you

@mauuuuu5 If your task does not allow for a separation or correction of the delimiters you could build a workflow where the data is read as a single column and later split into the real columns. With a try/switch you could determine which is the correct one.

Complications could arise if the delimiters are sometimes used as real data, quotes etc.

You could use the switch just to produce a list of the files and then use the standard CSV or file reader to do the import.

And then there is this. But you for sure are aware of …

2 Likes

Hi @mauuuuu5 , not that what I’m saying will solve your issue, but since you are reading all the files from the same folder, you don’t need to use a loop. The file readers (File Reader, CSV Reader, Excel Reader, etc) have embedded feature that allows you to read multiple files in the same folder with the “Files in folder” option:

For your issue, I was not able to open your rar file (probably because my winrar is too old), but if you have some pattern in the file names that you can see for semicolon delimiters, you can apply some rules within your loop (loop would be relevant in this case). So, the approach would be:

if (filename like "some_pattern") then
  delimiter = ";"
else
  delimiter = ","

And you can set the column_delimiter dynamically that way, depending on the file name:

2 Likes

Thank you I will check that out

Hi bruno I will check that out, thank you

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