error [Errno 2] No such file or directory

Asked

Viewed 245 times

0

For some reason I haven’t been able to identify the python is unable to locate the path.

for profile in sorted(profile_ids):
    path = '/FileStore/tables/'
    filename = 'google_analytics_data_%s_1.csv'
    with open(path + filename % profile.lower(), 'wt') as f:
        writer = csv.writer(f, lineterminator='\n')
        if __name__ == '__main__': main(sys.argv)
    print("Profile done. Next profile...")

Filenotfounderror: [Errno 2] No such file or directory: '/Filestore/Tables/google_analytics_data_

  • If you didn’t find it, it’s because it doesn’t exist. I saw that yours path starts with a slider, indicating that the path is absolute relative to the system root. Should that be true? It seems that you intended to access a relative path.

  • I understood that I should start with / because it is a DBFS walk and even taking out / the error persists

  • 1

    Replaces path = '/FileStore/tables/' for path =f'/FileStore/tables/'.

  • 1

    @Solkarped, solved the problem, thank you!

  • Glad you solved it. Just a hint: avoid using + to mount your path, for paths exists os.path.join()

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.