import name file in a columns

HELLO,
several days in a week I received file with a name like this 20230105.csv, 20230118.csv, 20230201.csv, etc.

In each csv file there is file and in the first row i have the number of that file: 00001, 00002, 00003, etc.

In each file i have multiples row and 3 columns (A, B, C), but i need to add 2 more column: 1 with the name of the file and 1 with the number of that file, in order to identify every row.

I attached the workflow I already have, because i use a loop in order to work multiple file and create an unique csv.

Could you please tell me if are there nodes that helps me with this?
Thanks

imm test con nome file IMN.knwf (67.9 KB)

Hey Gcas,

do you need to use the File Reader Complex Format? I attached a (incomplete) Workflow which might give you an idea. This currently will not work in a setting for multiple files since the column names change over the iterations. But I just wanted to give you an idea to utilize the CSV Reader in case you could use it since it gives you the option to attach the file path to the output.

csv_reader.knwf (15.8 KB)

Best regards
Lars

Hi @gcas ,

When you use the CSV reader node, you have the option to add the file path as a column too.

With it, you know the from file. At the Setting tabs, you can select the multi files options to bring all files from a folder, make it easier to bring all information at once.

After that, you will have all data as a table, just go on with your flow after that…

Is it was clear? Helped you?

Regards,

Denis

4 Likes

Hello,
Unfortunally I have to use “Complex Format” because datas arrive in a TXT (I import raw data and after I splitt with “cell splitter node”) and for this reason i cannot select the option "add path available in csv reader node

Unfortunally Not, because i have to use “complex format node” and i don’t have the chance to add path in an appended column.

You can also read .txt files with the CSV Reader, so this could work for your file structure as well and you could get rid of the File Reader and the Cell Splitter.

Hi @gcas

If you, despite the advice above, are still looking at the complex reader node: go to the Flow Variables tab of the node and in the white box of the file_selection/path, type a name and execute the node.

image

Use a variable to table column node and the file path will be available for processing thereafter.

5 Likes

THANKS! I already use this solution in order to group single files in a montly file.

The issue i cannot understand, how import the name of the file and the the code available in the first row of daily files, before to group in a montly file.

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