The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here

Using a function with a changing input value within a loop

rachel_lomaskyrachel_lomasky Member Posts: 52 Maven
edited November 2018 in Help

I'm trying to figure out why my macro is not being reset correctly within a loop.

 

I have a "Loop files."  Inside that I have a Generate Macro->Generate Report->Add section.

 

  • The Generate Macro creates a macro called "without_extension" with the function "replace(%{file_name},".tsv","")".
  • The Generate Report creates an Excel file with report name: %{without_extension}
  • The Add section adds to report name: %{without_extension}

I would expect, given three files in the directory being looped, three reports, each with one section added.  I get the three reports.  However, only one of the three has a section added.  If I delete that one from the directory being looped, a different one has the section.

 

Please help me understand what I am doing wrong setting the macro.

 

Many thanks in advance.

 

 

 

Best Answer

  • rachel_lomaskyrachel_lomasky Member Posts: 52 Maven
    Solution Accepted

    The problem is that it was being reinitialized within the loop.  It was user error.

Answers

  • Thomas_OttThomas_Ott RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 1,761 Unicorn

    Based on your explaination I think what's happening is that the the file is being overwritten each time the loop is finished. What you should do is name the report generated with the Loop Files macro %{file_name}. If the files that are being looped have unique file names then the reports will be generated with the filename. 

  • rachel_lomaskyrachel_lomasky Member Posts: 52 Maven

    Hi,

     

    Thank you.  Yes, the file names are based on the macro: 

    Excel file name = %{without_extension}.xls

  • Thomas_OttThomas_Ott RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 1,761 Unicorn

    try using %{file_name} from the Loop Files. that macro extracts the name of the file and then you can save it.

Sign In or Register to comment.