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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch 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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.