1

How to check if a file with specific names exists in current working directory in python? I tried following but gives error

import os
os.path.abspath(os.getcwd()).isfile('xyz.csv')
  • 1
    Does this answer your question? [How do I check whether a file exists without exceptions?](https://stackoverflow.com/questions/82831/how-do-i-check-whether-a-file-exists-without-exceptions) – AMC Feb 09 '20 at 23:56

1 Answers1

0

os.path.exists(path)

import os
os.path.exists(os.path.join(os.path.abspath(os.getcwd()), 'xyz.csv')
johnramsden
  • 291
  • 5
  • 14