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;








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


















6














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











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









6














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















6














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













6












6








6







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

















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
















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

















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

Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

199年 目錄 大件事 到箇年出世嗰人 到箇年死嗰人 節慶、風俗習慣 導覽選單