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

Compare two file name from a folder

Kumar_AyushKumar_Ayush Member Posts: 7 Learner I
how I can compare the file names which are read via loop files, if first 15 characters are same then merge those files and create a new file with those 15 characters followed by "_0_1"

Answers

  • BalazsBaranyBalazsBarany Administrator, Moderator, Employee-RapidMiner, RapidMiner Certified Analyst, RapidMiner Certified Expert Posts: 955 Unicorn
    Hi!

    I would use Loop Files first to build a file list. Activate "enable macros" and inside the loop add the current file name to a list. For example, create an empty example set before the loop with a "filename" attribute, Remember it, Recall it inside the loop and create a new example set with the current file name and append it.

    At the end of the loop, append the resulting collection. Now you have a list of file names.

    You can use Generate Attributes to get the first up to 15 characters of the file name, aggregate on the new short filename attribute and count the data. Then you know which files have 2 or more identical prefixes. Now you can work on this list e. g. with Loop Values, generate the new file name, Loop Files with the prefix, read the files, append their contents, and write them into the new file name. Maybe you would also delete the original files if necessary here.

    Regards,
    Balázs

Sign In or Register to comment.