简体   繁体   中英

How to check if a .dat file is present in a folder in python and if it is there,how to match it with associated csv?

I have a folder where I am getting .dat files whenever a .csv file is uploaded.

So, I want to check if a .dat file is present in a particular location and if it is there, only then do I want to upload my file to s3 using python and boto3.

Can anybody help me do this?

Try the following:

import os

path_to_your_file = ''
if os.path.isfile(path_to_your_file):
    print('File exists')
else:
    print("File doesn't exist")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM