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 UK remove the 'European Union' from its passport?
Were any of the books mentioned in this scene from the movie Hackers real?
How to rename multiple files in a directory at the same time
Capital gains on stocks sold to take initial investment off the table
Windows 10 lock screen - display my own random images
How to continually let my readers know what time it is in my story, in an organic way?
What metal is most suitable for a ladder submerged in an underground water tank?
Could there be something like aerobatic smoke trails in the vacuum of space?
To whom did Varys write those letters in Game of Thrones S8E5?
It is as easy as A B C, Figure out U V C from the given relationship
Why did the metro bus stop at each railway crossing, despite no warning indicating a train was coming?
Does the Rogue's Reliable Talent feature work for thieves' tools, since the rogue is proficient in them?
Are there microwaves to heat baby food at Brussels airport?
Using chord iii in a chord progression (major key)
What is the status of the Lannisters after Season 8 Episode 5, "The Bells"?
How could it be that 80% of townspeople were farmers during the Edo period in Japan?
Why commonly or frequently used fonts sizes are even numbers like 10px, 12px, 16px, 24px, or 32px?
Is there any deeper thematic meaning to the white horse that Arya finds in The Bells (S08E05)?
Cuban Primes
Meaning of "legitimate" in Carl Jung's quote "Neurosis is always a substitute for legitimate suffering."
Were any toxic metals used in the International Space Station?
tikz drawing rectangle discretized with triangle lattices and its centroids
Why would company (decision makers) wait for someone to retire, rather than lay them off, when their role is no longer needed?
How to redirect stdout to a file, and stdout+stderr to another one?
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 2 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
55 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
55 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
55 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,136310
1,136310
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
55 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
55 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
55 mins ago
@Damned_Newbie if the poster has answered your question, please press the little green tick next to his answer (top left).
– Keagan Allan
55 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