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
"[SOLVED] How to compare text files for equality"
tennenrishin
Member Posts: 177 Contributor II
I need to conditionally execute some operators in the event that there is a difference between the file contents of two files (s.txt and last_s.txt), which contain 2 csv fields (namely a regex and a comment) separated by ';'.
If the files contain multiple lines, the only solution I can think of involves looping and comparing each line one-by-one, maintaining a boolean macro along the way. Does anyone have a better idea to compare a whole text file? (Perhaps an easy way to obtain/construct some kind of file hash?)
If the files contain multiple lines, the only solution I can think of involves looping and comparing each line one-by-one, maintaining a boolean macro along the way. Does anyone have a better idea to compare a whole text file? (Perhaps an easy way to obtain/construct some kind of file hash?)
Tagged:
0
Answers
you can use the text extension for this: read the two files as documents, then use Documents to Data to store the complete documents, i.e. the contents of the files, in a single attribute: each row now contains an example with the complete document. For easier comparison, transpose the example set, then use Generate Attributes for comparison.
Please have a look at the attached process, and replace the Create Document operators with Read Document.
Best, Marius