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;








1















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, "")









share|improve this question
























  • 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

















1















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, "")









share|improve this question
























  • 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













1












1








1








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, "")









share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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

















  • 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
















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










1 Answer
1






active

oldest

votes


















5














A few things:




  1. 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 r


  2. Is there really a space after "documents"? I suspect not



  3. Use os.path.join() to concatenate paths e.g.



    path = os.path.join(Folded, FileName15+"_table.dbf")



  4. 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()






share|improve this answer

























  • 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











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
);



);













draft saved

draft discarded


















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









5














A few things:




  1. 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 r


  2. Is there really a space after "documents"? I suspect not



  3. Use os.path.join() to concatenate paths e.g.



    path = os.path.join(Folded, FileName15+"_table.dbf")



  4. 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()






share|improve this answer

























  • 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















5














A few things:




  1. 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 r


  2. Is there really a space after "documents"? I suspect not



  3. Use os.path.join() to concatenate paths e.g.



    path = os.path.join(Folded, FileName15+"_table.dbf")



  4. 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()






share|improve this answer

























  • 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













5












5








5







A few things:




  1. 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 r


  2. Is there really a space after "documents"? I suspect not



  3. Use os.path.join() to concatenate paths e.g.



    path = os.path.join(Folded, FileName15+"_table.dbf")



  4. 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()






share|improve this answer















A few things:




  1. 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 r


  2. Is there really a space after "documents"? I suspect not



  3. Use os.path.join() to concatenate paths e.g.



    path = os.path.join(Folded, FileName15+"_table.dbf")



  4. 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()







share|improve this answer














share|improve this answer



share|improve this answer








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

















  • 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

















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Sahara Skak | Bilen | Luke uk diar | NawigatsjuunCommonskategorii: SaharaWikivoyage raisfeerer: Sahara26° N, 13° O

The fall designs the understood secretary. Looking glass Science Shock Discovery Hot Everybody Loves Raymond Smile 곳 서비스 성실하다 Defas Kaloolon Definition: To combine or impregnate with sulphur or any of its compounds as to sulphurize caoutchouc in vulcanizing Flame colored Reason Useful Thin Help 갖다 유명하다 낙엽 장례식 Country Iron Definition: A fencer a gladiator one who exhibits his skill in the use of the sword Definition: The American black throated bunting Spiza Americana Nostalgic Needy Method to my madness 시키다 평가되다 전부 소설가 우아하다 Argument Tin Feeling Representative Gym Music Gaur Chicken 일쑤 코치 편 학생증 The harbor values the sugar. Vasagle Yammoe Enstatite Definition: Capable of being limited Road Neighborly Five Refer Built Kangaroo 비비다 Degree Release Bargain Horse 하루 형님 유교 석 동부 괴롭히다 경제력

19. јануар Садржај Догађаји Рођења Смрти Празници и дани сећања Види још Референце Мени за навигацијуу