generate attribute and filename in loop cycle

robbenrobben Member Posts: 9 Contributor II
edited November 2018 in Help
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

Answers

  • mdcmdc Member Posts: 58 Maven

    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
  • robbenrobben Member Posts: 9 Contributor II
    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
  • MariusHelfMariusHelf RapidMiner Certified Expert, Member Posts: 1,869 Unicorn
    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
  • robbenrobben Member Posts: 9 Contributor II
    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

  • MariusHelfMariusHelf RapidMiner Certified Expert, Member Posts: 1,869 Unicorn
    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
  • robbenrobben Member Posts: 9 Contributor II
    Both.
    Thx
  • MariusHelfMariusHelf RapidMiner Certified Expert, Member Posts: 1,869 Unicorn
    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
Sign In or Register to comment.