Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
MisterSmith
Helper I
Helper I

Defining if a parquet file exists in a Notebook

All

I need to check if a parquet file exists before running some code.  Is there a way of checking if a file exists in a notebook.  I just need it to return a true or false.

 

Thanks

 

Neil

1 ACCEPTED SOLUTION
MisterSmith
Helper I
Helper I

Thanks for this, but they didn't work as I needed to use wildcards in my pathway.  However this worked

 

Import glob

 

search_pattern = '/root_folder/*/*/*/target_file.txt'

 

files = glob.glob(search_pattern)
if files:
    print(f"File found: {files[0]}")
else:
    print("File not found.")

 

 

View solution in original post

2 REPLIES 2
MisterSmith
Helper I
Helper I

Thanks for this, but they didn't work as I needed to use wildcards in my pathway.  However this worked

 

Import glob

 

search_pattern = '/root_folder/*/*/*/target_file.txt'

 

files = glob.glob(search_pattern)
if files:
    print(f"File found: {files[0]}")
else:
    print("File not found.")

 

 

Houston-ho
Advocate I
Advocate I

if you are using python, you could read this website.

https://www.freecodecamp.org/news/how-to-check-if-a-file-exists-in-python/

Helpful resources

Announcements
September Fabric Update Carousel

Fabric Monthly Update - September 2025

Check out the September 2025 Fabric update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.