moest-np / center-randomize

Script is to assign exam centers to students
MIT License
753 stars 360 forks source link

fix/output directory generation not working as expected. #64

Closed padam-ghimire closed 6 months ago

padam-ghimire commented 6 months ago

It appears that OUTPUT_DIR is the base directory, and you're trying to create two files within it. However, when you're specifying the file paths for writing, you're not directly referencing OUTPUT_DIR for the second file.

You're using args.output, which only contains the filename, not the full path. To ensure that both files are created within the OUTPUT_DIR, you should use os.path.join() to construct the full file paths

create_dir(OUTPUT_DIR) # Create the output directory if not exists
with open(os.path.join(OUTPUT_DIR, 'school-center-distance.tsv'), 'w', encoding='utf-8') as intermediate_file, \
open(os.path.join(OUTPUT_DIR, args.output), 'w', encoding='utf-8') as a_file:

This way, both files will be created within the OUTPUT_DIR, resolving the issue with the output directory generation.

ashiishme commented 6 months ago

There are already 2 more PRs (#45 & #54 ) resolving the same issue. You should collaborate with any of them to come with common solution.

sumanashrestha commented 6 months ago

thank you for you time on this. #45 has been merged for this issue