Skip to content

error no such directory 'finished_searches' #1

Description

@jgstew

I got an error that the directory for the output file doesn't exist:

### suspicious links found
Writing output to finished_searches/test_links_2021_2021-02-01.csv
Traceback (most recent call last):
  File "main.py", line 98, in <module>
    f = open(output_path, 'w')
FileNotFoundError: [Errno 2] No such file or directory: 'finished_searches/test_links_2021_2021-02-01.csv'

The error line is here:

f = open(output_path, 'w')

The output path is defined here:

output_path = 'finished_searches/' + output_file_name + '_' + str(datetime.now().date()) + '.csv'

output_path = 'finished_searches/' + output_file_name + '_' + str(datetime.now().date()) + '.csv'

The folder finished_searches does not exist by default unless created manually. The python script doesn't attempt to make it for you if it is missing and the ReadMe doesn't mention adding it.

This should address this issue:

import os
if not os.path.exists('finished_searches'):
     os.makedirs('finished_searches')

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions