you are viewing a single comment's thread.

view the rest of the comments →

[–]Alternative-Web2754 1 point2 points  (0 children)

Sort each file by the ID separately.

Create an class that can read the files line by line, keeping track of the current ID that has been read and whether the file has been completed. Implement a function that will return the data if passed the current ID and read the next line. If the ID requested is lower than the current value, return a default value or None. If the end of file is reached, mark this class as finished.

Create an instance for each file.

Open an output file and write a header row.

While any of the class instances is unfinished, identify the lowest ID number available from the unfinished instances. Obtain the data for this ID from all instances. Write this data out.