Testing if os.path.exists with ArcPy?For Loop - Map Algebra (ArcGIS) using PythonCreating a Simple Join Script in PythonExecuteError: Failed to execute. Parameters are not valid. ERROR 000732: Layer Name or Table View: Dataset L does not existarcpy.MakeFeatureLayer_management for Feature Class within Feature Dataset with gdbClosing CSV file to read it again?Selecting records in SDE using table join in ArcPyFailed to execute (MakeTableView)Copying feature classes in feature dataset returns ERROR 000732: Input Features does not exist or is not supportedExporting to Excel gives ERROR 000732?Cannot find results of MakeFeatureLayer, cannot use SelectFeatureByAttribute
Why did the soldiers of the North disobey Jon?
How do I know which cipher suites can be disabled?
Why were the bells ignored in S8E5?
Can anyone give me examples of the relative-determinative 'which'?
Why can't I share a one use code with anyone else?
What do you call the hair or body hair you trim off your body?
How does Ctrl+c and Ctrl+v work?
Which creature is depicted in this Xanathar's Guide illustration of a war mage?
labelled end points on logic diagram
Can my American children re-enter the USA by International flight with a passport card? Being that their passport book has expired
God-Pharaoh's Statue and Finale Of Promise
Are there microwaves to heat baby food at Brussels airport?
Were any toxic metals used in the International Space Station?
What is this weird d12 for?
Why did the metro bus stop at each railway crossing, despite no warning indicating a train was coming?
What was Varys trying to do at the beginning of S08E05?
How to handle professionally if colleagues has referred his relative and asking to take easy while taking interview
What do the "optional" resistor and capacitor do in this circuit?
Does the Rogue's Reliable Talent feature work for thieves' tools, since the rogue is proficient in them?
Network latencies between opposite ends of the Earth
Windows 10 lock screen - display my own random images
Given 0s on Assignments with suspected and dismissed cheating?
Testing blind license applicants
What is the status of the Lannisters after Season 8 Episode 5, "The Bells"?
Testing if os.path.exists with ArcPy?
For Loop - Map Algebra (ArcGIS) using PythonCreating a Simple Join Script in PythonExecuteError: Failed to execute. Parameters are not valid. ERROR 000732: Layer Name or Table View: Dataset L does not existarcpy.MakeFeatureLayer_management for Feature Class within Feature Dataset with gdbClosing CSV file to read it again?Selecting records in SDE using table join in ArcPyFailed to execute (MakeTableView)Copying feature classes in feature dataset returns ERROR 000732: Input Features does not exist or is not supportedExporting to Excel gives ERROR 000732?Cannot find results of MakeFeatureLayer, cannot use SelectFeatureByAttribute
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am having trouble getting the os.path.exists to recognize that a file exists. I keep getting "File does not exist". I reduced the code to the absolute necessary to address my question. I believe everything relevant is in there.
import os
FileName15 ="Stuck"
Folded = arcpy.GetParameterAsText(4)
if Folded == '#' or not Folded:
Folded = "C:Documents test.gdb\" # provide a default value if unspecified
if os.path.exists(Folded+FileName15+"_table.dbf") == True:
print ("It does exist")
print Folded+FileName15+"_table.dbf"
# Process: Delete
arcpy.Delete_management(Folded+Name15+"_table", "Table")
# Process Create Table
arcpy.CreateTable_management(Folded, FileName15+"_table",Template_Shell, "")
elif os.path.exists(Folded+FileName15+"_table.dbf") == False:
print ("File does not exist")
print Folded+FileName15+"_table.dbf"
# Process Create Table
arcpy.CreateTable_management(Folded, FileName15+"_table",Template_Shell, "")
arcpy python
add a comment |
I am having trouble getting the os.path.exists to recognize that a file exists. I keep getting "File does not exist". I reduced the code to the absolute necessary to address my question. I believe everything relevant is in there.
import os
FileName15 ="Stuck"
Folded = arcpy.GetParameterAsText(4)
if Folded == '#' or not Folded:
Folded = "C:Documents test.gdb\" # provide a default value if unspecified
if os.path.exists(Folded+FileName15+"_table.dbf") == True:
print ("It does exist")
print Folded+FileName15+"_table.dbf"
# Process: Delete
arcpy.Delete_management(Folded+Name15+"_table", "Table")
# Process Create Table
arcpy.CreateTable_management(Folded, FileName15+"_table",Template_Shell, "")
elif os.path.exists(Folded+FileName15+"_table.dbf") == False:
print ("File does not exist")
print Folded+FileName15+"_table.dbf"
# Process Create Table
arcpy.CreateTable_management(Folded, FileName15+"_table",Template_Shell, "")
arcpy python
Please format your code correctly using the
– Marcelo Villa
3 hours ago
if you copy the full file name, open the python shell and paste it in the parameter for os.path.exists do you get True?
– atxgis
3 hours ago
add a comment |
I am having trouble getting the os.path.exists to recognize that a file exists. I keep getting "File does not exist". I reduced the code to the absolute necessary to address my question. I believe everything relevant is in there.
import os
FileName15 ="Stuck"
Folded = arcpy.GetParameterAsText(4)
if Folded == '#' or not Folded:
Folded = "C:Documents test.gdb\" # provide a default value if unspecified
if os.path.exists(Folded+FileName15+"_table.dbf") == True:
print ("It does exist")
print Folded+FileName15+"_table.dbf"
# Process: Delete
arcpy.Delete_management(Folded+Name15+"_table", "Table")
# Process Create Table
arcpy.CreateTable_management(Folded, FileName15+"_table",Template_Shell, "")
elif os.path.exists(Folded+FileName15+"_table.dbf") == False:
print ("File does not exist")
print Folded+FileName15+"_table.dbf"
# Process Create Table
arcpy.CreateTable_management(Folded, FileName15+"_table",Template_Shell, "")
arcpy python
I am having trouble getting the os.path.exists to recognize that a file exists. I keep getting "File does not exist". I reduced the code to the absolute necessary to address my question. I believe everything relevant is in there.
import os
FileName15 ="Stuck"
Folded = arcpy.GetParameterAsText(4)
if Folded == '#' or not Folded:
Folded = "C:Documents test.gdb\" # provide a default value if unspecified
if os.path.exists(Folded+FileName15+"_table.dbf") == True:
print ("It does exist")
print Folded+FileName15+"_table.dbf"
# Process: Delete
arcpy.Delete_management(Folded+Name15+"_table", "Table")
# Process Create Table
arcpy.CreateTable_management(Folded, FileName15+"_table",Template_Shell, "")
elif os.path.exists(Folded+FileName15+"_table.dbf") == False:
print ("File does not exist")
print Folded+FileName15+"_table.dbf"
# Process Create Table
arcpy.CreateTable_management(Folded, FileName15+"_table",Template_Shell, "")
arcpy python
arcpy python
edited 3 hours ago
PolyGeo♦
54.3k1782251
54.3k1782251
asked 3 hours ago
Damned_NewbieDamned_Newbie
195
195
Please format your code correctly using the
– Marcelo Villa
3 hours ago
if you copy the full file name, open the python shell and paste it in the parameter for os.path.exists do you get True?
– atxgis
3 hours ago
add a comment |
Please format your code correctly using the
– Marcelo Villa
3 hours ago
if you copy the full file name, open the python shell and paste it in the parameter for os.path.exists do you get True?
– atxgis
3 hours ago
Please format your code correctly using the
button.– Marcelo Villa
3 hours ago
Please format your code correctly using the
button.– Marcelo Villa
3 hours ago
if you copy the full file name, open the python shell and paste it in the parameter for os.path.exists do you get True?
– atxgis
3 hours ago
if you copy the full file name, open the python shell and paste it in the parameter for os.path.exists do you get True?
– atxgis
3 hours ago
add a comment |
1 Answer
1
active
oldest
votes
A few things:
Use "raw strings" to avoid issues with Windows path separators (backslashes) being interpreted as escape characters, e.g.
Folded = r"C:Documents test.gdb"
^ note the rIs there really a space after "documents"? I suspect not
Use
os.path.join()
to concatenate paths e.g.path = os.path.join(Folded, FileName15+"_table.dbf")
There's no file on the filesystem which directly corresponds to a table/feature class in a gdb, only ArcGIS knows what's in these. What you really want is
arcpy.Exists()
you are right on every count. I implemented your changes. Unfortunately now my script no longer recognizes arcpy as a global module. if arcpy.exists(table_name) == True: AttributeError: 'module' object has no attribute 'exists'
– Damned_Newbie
3 hours ago
4
Python is case sensitive. Use an upper case E in arcpy.Exists()
– GBG
2 hours ago
1
@Damned_Newbie if the poster has answered your question, please press the little green tick next to his answer (top left).
– Keagan Allan
1 hour ago
@Damned_Newbie you received an error because you usedarcpy.exists
which is not correct. It isarcpy.Exists()
with capitalE
. Please look at the answer carefully. Here is the function from the esri help: desktop.arcgis.com/en/arcmap/10.3/analyze/arcpy-functions/…
– ahmadhanb
12 mins ago
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "79"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f322749%2ftesting-if-os-path-exists-with-arcpy%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
A few things:
Use "raw strings" to avoid issues with Windows path separators (backslashes) being interpreted as escape characters, e.g.
Folded = r"C:Documents test.gdb"
^ note the rIs there really a space after "documents"? I suspect not
Use
os.path.join()
to concatenate paths e.g.path = os.path.join(Folded, FileName15+"_table.dbf")
There's no file on the filesystem which directly corresponds to a table/feature class in a gdb, only ArcGIS knows what's in these. What you really want is
arcpy.Exists()
you are right on every count. I implemented your changes. Unfortunately now my script no longer recognizes arcpy as a global module. if arcpy.exists(table_name) == True: AttributeError: 'module' object has no attribute 'exists'
– Damned_Newbie
3 hours ago
4
Python is case sensitive. Use an upper case E in arcpy.Exists()
– GBG
2 hours ago
1
@Damned_Newbie if the poster has answered your question, please press the little green tick next to his answer (top left).
– Keagan Allan
1 hour ago
@Damned_Newbie you received an error because you usedarcpy.exists
which is not correct. It isarcpy.Exists()
with capitalE
. Please look at the answer carefully. Here is the function from the esri help: desktop.arcgis.com/en/arcmap/10.3/analyze/arcpy-functions/…
– ahmadhanb
12 mins ago
add a comment |
A few things:
Use "raw strings" to avoid issues with Windows path separators (backslashes) being interpreted as escape characters, e.g.
Folded = r"C:Documents test.gdb"
^ note the rIs there really a space after "documents"? I suspect not
Use
os.path.join()
to concatenate paths e.g.path = os.path.join(Folded, FileName15+"_table.dbf")
There's no file on the filesystem which directly corresponds to a table/feature class in a gdb, only ArcGIS knows what's in these. What you really want is
arcpy.Exists()
you are right on every count. I implemented your changes. Unfortunately now my script no longer recognizes arcpy as a global module. if arcpy.exists(table_name) == True: AttributeError: 'module' object has no attribute 'exists'
– Damned_Newbie
3 hours ago
4
Python is case sensitive. Use an upper case E in arcpy.Exists()
– GBG
2 hours ago
1
@Damned_Newbie if the poster has answered your question, please press the little green tick next to his answer (top left).
– Keagan Allan
1 hour ago
@Damned_Newbie you received an error because you usedarcpy.exists
which is not correct. It isarcpy.Exists()
with capitalE
. Please look at the answer carefully. Here is the function from the esri help: desktop.arcgis.com/en/arcmap/10.3/analyze/arcpy-functions/…
– ahmadhanb
12 mins ago
add a comment |
A few things:
Use "raw strings" to avoid issues with Windows path separators (backslashes) being interpreted as escape characters, e.g.
Folded = r"C:Documents test.gdb"
^ note the rIs there really a space after "documents"? I suspect not
Use
os.path.join()
to concatenate paths e.g.path = os.path.join(Folded, FileName15+"_table.dbf")
There's no file on the filesystem which directly corresponds to a table/feature class in a gdb, only ArcGIS knows what's in these. What you really want is
arcpy.Exists()
A few things:
Use "raw strings" to avoid issues with Windows path separators (backslashes) being interpreted as escape characters, e.g.
Folded = r"C:Documents test.gdb"
^ note the rIs there really a space after "documents"? I suspect not
Use
os.path.join()
to concatenate paths e.g.path = os.path.join(Folded, FileName15+"_table.dbf")
There's no file on the filesystem which directly corresponds to a table/feature class in a gdb, only ArcGIS knows what's in these. What you really want is
arcpy.Exists()
edited 1 hour ago
Vince
15k33050
15k33050
answered 3 hours ago
mikewattmikewatt
1,146310
1,146310
you are right on every count. I implemented your changes. Unfortunately now my script no longer recognizes arcpy as a global module. if arcpy.exists(table_name) == True: AttributeError: 'module' object has no attribute 'exists'
– Damned_Newbie
3 hours ago
4
Python is case sensitive. Use an upper case E in arcpy.Exists()
– GBG
2 hours ago
1
@Damned_Newbie if the poster has answered your question, please press the little green tick next to his answer (top left).
– Keagan Allan
1 hour ago
@Damned_Newbie you received an error because you usedarcpy.exists
which is not correct. It isarcpy.Exists()
with capitalE
. Please look at the answer carefully. Here is the function from the esri help: desktop.arcgis.com/en/arcmap/10.3/analyze/arcpy-functions/…
– ahmadhanb
12 mins ago
add a comment |
you are right on every count. I implemented your changes. Unfortunately now my script no longer recognizes arcpy as a global module. if arcpy.exists(table_name) == True: AttributeError: 'module' object has no attribute 'exists'
– Damned_Newbie
3 hours ago
4
Python is case sensitive. Use an upper case E in arcpy.Exists()
– GBG
2 hours ago
1
@Damned_Newbie if the poster has answered your question, please press the little green tick next to his answer (top left).
– Keagan Allan
1 hour ago
@Damned_Newbie you received an error because you usedarcpy.exists
which is not correct. It isarcpy.Exists()
with capitalE
. Please look at the answer carefully. Here is the function from the esri help: desktop.arcgis.com/en/arcmap/10.3/analyze/arcpy-functions/…
– ahmadhanb
12 mins ago
you are right on every count. I implemented your changes. Unfortunately now my script no longer recognizes arcpy as a global module. if arcpy.exists(table_name) == True: AttributeError: 'module' object has no attribute 'exists'
– Damned_Newbie
3 hours ago
you are right on every count. I implemented your changes. Unfortunately now my script no longer recognizes arcpy as a global module. if arcpy.exists(table_name) == True: AttributeError: 'module' object has no attribute 'exists'
– Damned_Newbie
3 hours ago
4
4
Python is case sensitive. Use an upper case E in arcpy.Exists()
– GBG
2 hours ago
Python is case sensitive. Use an upper case E in arcpy.Exists()
– GBG
2 hours ago
1
1
@Damned_Newbie if the poster has answered your question, please press the little green tick next to his answer (top left).
– Keagan Allan
1 hour ago
@Damned_Newbie if the poster has answered your question, please press the little green tick next to his answer (top left).
– Keagan Allan
1 hour ago
@Damned_Newbie you received an error because you used
arcpy.exists
which is not correct. It is arcpy.Exists()
with capital E
. Please look at the answer carefully. Here is the function from the esri help: desktop.arcgis.com/en/arcmap/10.3/analyze/arcpy-functions/…– ahmadhanb
12 mins ago
@Damned_Newbie you received an error because you used
arcpy.exists
which is not correct. It is arcpy.Exists()
with capital E
. Please look at the answer carefully. Here is the function from the esri help: desktop.arcgis.com/en/arcmap/10.3/analyze/arcpy-functions/…– ahmadhanb
12 mins ago
add a comment |
Thanks for contributing an answer to Geographic Information Systems Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f322749%2ftesting-if-os-path-exists-with-arcpy%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Please format your code correctly using the
– Marcelo Villa
3 hours ago
if you copy the full file name, open the python shell and paste it in the parameter for os.path.exists do you get True?
– atxgis
3 hours ago