I have a python script which accesses a mapped network drive on Windows OS and creates a file in the mapped location to write. Here's the code to write.
output_file = f"{output_dirPath}/{directory_name}{output_suffix}"
with open(output_file, 'w') as file:
file.write("Sample Name\tFilename\tSample Type\tProcessing Setting\tReference\n")
for path in file_paths:
file_name = os.path.basename(path) # Extract the file name from the path
final_filename = os.path.splitext(file_name)[0] # Remove the .bam extension
file.write(f"{final_filename}\t{path}\t{sample_type}\t{processing_setting}\t{reference}\n")
Where, output_dirPath is the mapped network drive which I am accessing as below
output_dirPath = "//abc/data/lab/Archives/Test/{}".format(directory_name)
Directory name is can be any alphanumeric string with spaces, _, and - in them.
The output suffix is _template.txt
When I run this script the section of the code (not mentioned here runs and unzips the files) however does not write to a file and gives following error.
Traceback (most recent call last):
File "Template.py", line 76, in <module>
with open(output_file, 'w') as file:
^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '//abc/data/lab/Archives/Test/Output Folder abc 1ef3D00.example/Output Folder abc 1ef3D00.example_bamTemplate.txt'