Search a CSV-file with python [duplicate]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Search a CSV-file with python [duplicate]



This question already has an answer here:



I want to search a CSV-File with python2 on the Raspberrry Pi. If the file is not found the program should generate it. How I can search a file and can decide with an if-statment if there is CSV-file or not?



This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.





Welcome to Stackoverflow. Did you try anything yourself? Python does have great csv support, also csv is basically a txt-file so it shouldn't be hard either way. Read also: stackoverflow.com/help/mcve
– Bernhard
Aug 8 at 6:58





os.path.exists('path/to/csvfile') will return False if the specified file does nor exist.
– John Anderson
Aug 8 at 7:01


os.path.exists('path/to/csvfile')




1 Answer
1



as @John Anderson said you can use the os module's os.path.


os


if os.path.exists('path/to/your/csvfile/') is True:
print("Do something")

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard