|
POST
|
I amended the code, the error message indicated there was an existing Feature class. The arcpy.copymanagement works, the arcpy.deletemanagement still fails?? sdeConnection = arcpy.env.workspace = r"C:\database_connections\GIST.sde" outWorkspace =sdeConnection datadir = arcpy.env.workspace = r"\\server1\\GISData\Highway_Layer_Update" ##print datadir try: ##check file exists here fcList = arcpy.ListFeatureClasses() for i in fcList: if i == "Bus Stops.shp": ### no file #outFeatureClass = os.path.join(outWorkspace, shapefile.strip(".shp")) #arcpy.CopyFeatures_management(shapefile, outFeatureClass) print i fcnewbus = "GISADMIN.BUSSTOPS_NEW" outbus = os.path.join(outWorkspace, fcnewbus ) arcpy.CopyFeatures_management(i, outbus) arcpy.DeleteFeatures_management(r"\\server1\\GISData\Highway_Layer_Update\Bus Stops.shp") ## #arcpy.DeleteFeatures_management(datadir + "\Bus Stops.shp") elif i == "Cluster_sites.shp": ## file exsists print i fcnewcluster = "GISADMIN.CLUSTERS_NEW" outcluster = os.path.join(outWorkspace, fcnewcluster) arcpy.CopyFeatures_management(i, outcluster) ## WORKS!!! arcpy.DeleteFeatures_management(r"r"\\server1\\GISData\Highway_Layer_Update\Cluster_sites.shp") ## DELETE FAILS ##arcpy.DeleteFeatures_management(datadir + "\Cluster_sites_2014.shp") Error message existing connexion forcibly closed???? Message File Name Line Position Traceback __call__ C:\Program Files (x86)\PyScripter\Lib\rpyc.zip\rpyc\core\netref.py 196 syncreq C:\Program Files (x86)\PyScripter\Lib\rpyc.zip\rpyc\core\netref.py 71 sync_request C:\Program Files (x86)\PyScripter\Lib\rpyc.zip\rpyc\core\protocol.py 431 serve C:\Program Files (x86)\PyScripter\Lib\rpyc.zip\rpyc\core\protocol.py 379 _recv C:\Program Files (x86)\PyScripter\Lib\rpyc.zip\rpyc\core\protocol.py 337 recv C:\Program Files (x86)\PyScripter\Lib\rpyc.zip\rpyc\core\channel.py 50 read C:\Program Files (x86)\PyScripter\Lib\rpyc.zip\rpyc\core\stream.py 166 exceptions.EOFError: [Errno 10054] An existing connection was forcibly closed by the remote host
... View more
12-29-2015
11:15 AM
|
0
|
2
|
469
|
|
POST
|
Hi James, That provides a far more useful error message. Thanks Clive
... View more
12-29-2015
06:19 AM
|
1
|
4
|
2303
|
|
POST
|
A typo, I just printed out the except block message, not helpful. Thanks.
... View more
12-29-2015
05:58 AM
|
0
|
0
|
2303
|
|
POST
|
I need to automate a shapefile to feature class update. The problem is that the shapefile name and output (feature class) are not the same. So I need to hard code the shp & features. I have a loop that works, printing out the shapefile names. The code fails when I try to use the arcpy.CopyFeatures_management function. Can anyone see what is causing the arcpy.CopyFeatures_management function to fail?? Would appreciate a suggestion to resolve the issue. import arcpy
import glob
import os
import sys
import csv
import time
import smtplib
import shutil
import ftplib
sdeConnection = arcpy.env.workspace = r"C:\database_connections\GIST.sde"
outWorkspace =sdeConnection
datadir = arcpy.env.workspace = r"\\server1\ER Shares\Highway_Layer_Update" ## URL works
try:
#check file exists here
fcList = arcpy.ListFeatureClasses()
## Feature classes are hard coded
## Feature classes are hard coded
for i in fcList:
if i == "Bus Stops.shp":
#outFeatureClass = os.path.join(outWorkspace, shapefile.strip(".shp"))
#arcpy.CopyFeatures_management(shapefile, outFeatureClass)
print i ## NO shp
fcnew = "GISADMIN.KCC_BUSSTOPS_NEW"
outFeatureClass = os.path.join(outWorkspace, fcnew )
arcpy.CopyFeatures_management(i, outFeatureClass)
arcpy.DeleteFeatures_management(i)
elif i == "Cluster_sites_2014.shp":
print i ## Prints shp
fcnew = "GISADMIN.KCC_KHS_CLUSTERS_2014_NEW"
outFeatureClass = os.path.join(outWorkspace, fcnew ) ## Fails
printoutFeatureClass
arcpy.CopyFeatures_management(i, outFeatureClass)
arcpy.DeleteFeatures_management(i)
else:
print "No file"
except:
print ("No File found program terminated") ## This is printed out Message was edited by: Dan Patterson
I formatted your code to make it easier to read... use the syntax highlighting ... >> ... and select Python
... View more
12-29-2015
04:47 AM
|
0
|
13
|
5652
|
|
POST
|
Greetings, I am trying to get a basic sql statement working using arcpy.ArcSDESQLExecute, it keeps throwing an error. I need to run an external sql with joins, etc in .sql file. ##The code import arcpy,sys,csv # Python environment arcpy.env.overwriteOutput = True workspace = arcpy.env.workspace = r"C:\database_connections\K2_Master_Training.sde" sde_conn = arcpy.ArcSDESQLExecute(r"C:\database_connections\K2_Master_Training.sde") sql = "SELECT * FROM tbSite" sqlresult = sde_conn.execute(sql) for i in sqlresult: print i Get the following error?? AttributeError: AttributeError(u'ArcSDESQLExecute: SreamBindOutputColumn ArcSDE Error -65 \uec5c',) If would appreciate assistance getting this working, to read a sql file. Thanks, Clive
... View more
12-23-2015
09:56 AM
|
0
|
2
|
2965
|
|
POST
|
Hi Darren, Thanks, when I added the .shp the script worked. Got back Cluster_sites.shp Fixed and Mobile Camera.shp Road_Traffic_Collisions.shp <type 'file'>
... View more
12-22-2015
10:13 AM
|
0
|
0
|
232
|
|
POST
|
fcList = arcpy.ListFeatureClasses() for i in fcList: print "1" ++ shapefile Returns an error
... View more
12-22-2015
10:06 AM
|
0
|
0
|
1928
|
|
POST
|
Hi Chris, If I type: fcList = arcpy.ListFeatureClasses() for i in fcList: print i Then I get the list of shapefiles as expected. Cluster_sites.shp Fixed and Mobile Camera.shp Road_Traffic_Collisions.shp <type 'file'> The aim is to use the if, elif block to use the CopyFeature command, if the shapefile exsists. Thanks, Clive
... View more
12-22-2015
10:04 AM
|
0
|
0
|
1928
|
|
POST
|
datadir = arcpy.env.workspace = r"D:/DATA/HML" try: # If directory doesn't exist make it if not os.path.isdir(datadir): os.mkdir(datadir) # Change the local directory to where you want to put the data os.chdir(datadir) #check file exists here? fcList = arcpy.ListFeatureClasses() for i in fcList: if i == "Bus Stops": print "1" ++ shapefile elif i == "Cluster_Sites_2014": print shapefile else: print "2" except: print"error" There code runs, the appearance is copy/paste. If the indentation was wrong, it would not compile!! It prints: 2 2 2 <type file> I need the loop to work. If the file exists it runs a command, then jumps to the next item. If the file does not exist it jumps to the next item.
... View more
12-22-2015
09:50 AM
|
1
|
6
|
1928
|
|
POST
|
I have a list of shapefiles that I need to select within a loop, to see if the file is there or not. I tried several loops if, elif ... Just get an error??? I would appreciate any suggestions, to get this working. #check file exists here? fcList = arcpy.ListFeatureClasses() for shapefile in fcList: if shapefile == "Bus Stops": print "1" ++ shapefile elif shapefile == "Cluster_Sites": print "2" ++ "shapefile" elif shapefile == "Highway Boundary": print "3" ++ "shapefile" elif shapefile == "Street Lighting": print "4" ++ "shapefile" elif shapefile == "Road_Traffic_Collisions": print "5" ++ "shapefile" else: print "end" The code prints: end end end <type file> There are 3 shapefiles in the directory. There could be 0 to10 shapefiles
... View more
12-22-2015
09:19 AM
|
0
|
10
|
4519
|
|
POST
|
HI Vince, I was trying to use Python DESCRIBE.. I do not have access to the Oracle PL/SQL to run queries.. Seems have to use Oracle Client not Python??
... View more
06-09-2015
01:01 AM
|
0
|
1
|
3712
|
|
POST
|
OK It seems the problem was the line OWNER = 'GISADMIN' THIS WORKS... sql_statement = ' '.join(( "SELECT *", "FROM USER_TAB_PRIVS", "WHERE OWNER LIKE 'GISADMN'" ))
... View more
06-02-2015
06:04 AM
|
0
|
2
|
3712
|
|
POST
|
I get an error when I include OBJECT_TYPE = 'FeatureClass' or OBJECT_TYPE = 'Table' (?????) Execute SQL Statement: SELECT * FROM USER_TAB_PRIVS WHERE OBJECT_TYPE = 'Table' 'ascii' codec can't encode character u'\uf35c' in position 52: ordinal not in range(128) This is weird as the data is encoded as [u'data', u'more-data', u'more-data', u'more-data', u'more-data', ] for each row, to encode as csv???
... View more
06-02-2015
03:43 AM
|
0
|
3
|
3712
|
|
POST
|
Hi, Thanks to Bill, Blake and Joshua for the inputs... This query works: sql_statement = ' ' .join(( "SELECT *", "FROM USER_TAB_PRIVS", "WHERE OWNER = 'GISADMIN'", )) The query works, but now I need to get back the table names and understand the data. The data returned is not what I expected to get back eg: Data name Owner Permission ?? ?? LIBRARY GISADMIN SELECT NO NO >> expected YES
... View more
06-02-2015
03:42 AM
|
0
|
0
|
3712
|
|
POST
|
I am trying to: 1) Determine which tables to select to get the User Privileges 2) Run an arcpy script to get all FeatureClass, Table priviliges I get an ORA-00936 error (933 ORA-00933: SQL command not properly ended) The SQL statement is: sql_statement = "SELECT OWNER,OBJECT_TYPE,OBJECT_NAME \ FROM DBA* \ WHERE OWNER = 'GISADMIN' and OBJECT_TYPE = 'TABLE'" The SQL appears to be correct??? Don't understand why it is returning this error?? Thanks, Clive
... View more
05-29-2015
08:41 AM
|
0
|
11
|
8208
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 02-22-2021 04:17 AM | |
| 1 | 02-05-2021 07:18 AM | |
| 1 | 11-06-2020 07:13 AM | |
| 2 | 07-07-2021 04:20 AM | |
| 1 | 01-07-2021 02:53 PM |
| Online Status |
Offline
|
| Date Last Visited |
02-23-2024
07:07 PM
|