VSCode unable to read file even though it's there in the defined path

265
3
Jump to solution
02-29-2024 08:25 AM
Ed_
by MVP Regular Contributor
MVP Regular Contributor

So I exported the code from a model builder model in ArcGIS Pro 3.1. I then opened the code in VScode to firstly see whether the code is running fine from VScode or not.

So the code fails where it has to read an xlsx file, even though the file does exist in the location path defined.

Is this a path issue? How can I fix this?

Error:

ERROR 000732: Input Excel File: Dataset \bc\efs\PowerBI\EPGMD\INNOVATION UNIT\CulturalArts\Grants.xlsx does not exist or is not supported

 

Code line:

Grants_xlsx = "\\bc\efs\PowerBI\EPGMD\INNOVATION UNIT\CulturalArts\Grants.xlsx"

# Process: Excel To Table (Excel To Table) (conversion)
    Grants_ExcelToTable = "O:\\psd\\Ed\\GeocodeProject\\ModelGeodatabase.gdb\\Grants_ExcelToTable"
    arcpy.conversion.ExcelToTable(Input_Excel_File=Grants_xlsx, Output_Table=Grants_ExcelToTable, Sheet="Grants")

 

File location:

Ed__0-1709223884729.png

 

Question | Analyze | Visualize
0 Kudos
1 Solution

Accepted Solutions
CodyPatterson
Occasional Contributor III

Hey @Ed_ 

In your error I see that the first \ in your line isn't showing as double, you may try this:

Grants_xlsx = r"\\bc\efs\PowerBI\EPGMD\INNOVATION UNIT\CulturalArts\Grants.xlsx"

This may take in the second \.

Hope that helps!

Cody

View solution in original post

0 Kudos
3 Replies
CodyPatterson
Occasional Contributor III

Hey @Ed_ 

In your error I see that the first \ in your line isn't showing as double, you may try this:

Grants_xlsx = r"\\bc\efs\PowerBI\EPGMD\INNOVATION UNIT\CulturalArts\Grants.xlsx"

This may take in the second \.

Hope that helps!

Cody

0 Kudos
Ed_
by MVP Regular Contributor
MVP Regular Contributor

Yup that did it, cheers for the super quick response 🙂

Question | Analyze | Visualize
0 Kudos
CodyPatterson
Occasional Contributor III

Hey @Ed_ 

No problem at all, glad to help out!

Cody

0 Kudos