RapidMiner

RapidMiner

generate attribute and filename in loop cycle

Contributor II

generate attribute and filename in loop cycle

Goodmorning,
i am new at rapidminer and discovering it as great for ETL and analysis tasks.
Just a question i didn't find documented even if browsing around.
I need to load some csv files, treat these data adding an attribute to corrispondent dataset recorded the name of the file where they come from and then apped it in a unique dataset.
I used loop files operator with read csv, generate attributes subprocess operators and then an append operator.
But in generate attributes right now i am just able to write a fix name for all the files.
I don't know how to reference in generate attributes operator the changing file name for each iteration coming from loop files operator.
Is there any way to do it (for example with any process parameter) directly on Edit List in function descriptions or is there another way?
Thanks in advance
7 REPLIES
mdc
Regular Contributor

Re: generate attribute and filename in loop cycle


Try to use 'file name macro' parameter of the 'Loop Files' operator. This can be done by adding %{file_name} as a value to your attribute.
I'm not actually sure if this is what your looking for, but you can post a sample of  your process so it's more clear.

Matthew
Contributor II

Re: generate attribute and filename in loop cycle

Matthew,
it's perfectly what i was looking for. Thanks a lot
is there any way to get filename without extension? I mean if the filename is ABC.csv just ABC
Thanks
Roberto
Super Contributor

Re: generate attribute and filename in loop cycle

If you are familiar with regular expressions, you can remove the extension from the original filename with the Generate Macro operator and the ReplaceAll() function.

Best regards,
Marius
Contributor II

Re: generate attribute and filename in loop cycle

Thanks Marius,
i will check that solution deepening regular expressions
Apart, english manual, operator Reference and AccademicUse that i read, is there any other manual where to study specific rapidminer code programming (i mean the code programming and not the visual one?)
Thanks in advance
Roberto

Super Contributor

Re: generate attribute and filename in loop cycle

Do you mean actual Java programming, i.e. extending RapidMiner with custom operators and extensions? Or do you mean the "code" used in Generate Attribute and Generate Macro?

Best regards,
Marius
Contributor II

Re: generate attribute and filename in loop cycle

Both.
Thx
Super Contributor

Re: generate attribute and filename in loop cycle

The RapidMiner Extension Guide available from our documentation site describes how to create custom operators. For Generate Attributes the only documentation is the one available directly in the operator itself: if you open the expression editor, at the bottom a categorized list of functions is displayed. If you hover the mouse over a function name a tooltip is shown describing the syntax of the respective function.

Best regards,
Marius