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
Were any toxic metals used in the International Space Station?
Should I communicate in my applications that I'm unemployed out of choice rather than because nobody will have me?
Does this "yield your space to an ally" rule my 3.5 group uses appear anywhere in the official rules?
Why would company (decision makers) wait for someone to retire, rather than lay them off, when their role is no longer needed?
What is the status of the Lannisters after Season 8 Episode 5, "The Bells"?
What is this weird d12 for?
Can a tourist shoot a gun in the USA?
Wireless headphones interfere with Wi-Fi signal on laptop
What do you call the hair or body hair you trim off your body?
Why doesn't Iron Man's action affect this person in Endgame?
What do the "optional" resistor and capacitor do in this circuit?
Windows 10 lock screen - display my own random images
It is as easy as A B C, Figure out U V C from the given relationship
How to describe a building set which is like LEGO without using the "LEGO" word?
With today's technology, could iron be smelted at La Rinconada?
UUID type for NEWID()
Network latencies between opposite ends of the Earth
Given 0s on Assignments with suspected and dismissed cheating?
Using chord iii in a chord progression (major key)
Why did the soldiers of the North disobey Jon?
tikz drawing rectangle discretized with triangle lattices and its centroids
Does it matter what way the tires go if no directional arrow?
labelled end points on logic diagram
Do people who work at research institutes consider themselves "academics"?
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 thebutton.
– 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 thebutton.
– 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 thebutton.
– 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
2 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
38 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
2 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
38 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
2 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
38 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 54 mins 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
2 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
38 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
2 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
38 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
2 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
2 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
38 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
38 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
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