POST
|
Joshua, Thanks for the response and useful info. We just discovered what was happening: The scheduled task we were running was trying to connect to data in a SQL database on another server. We needed to install the SQL-client software on the server in order to connect and communicate with the SQL server correctly. During our tests, our SQL data and ArcServer were both on the same box, and the client was installed with the SQL install. A simple thing to overlook - maybe the client software should be an option during the Server install, or even the Desktop install? Thanks again for your response.
... View more
02-18-2015
01:47 PM
|
0
|
0
|
254
|
POST
|
I have a server with Server and Desktop installed locally. I'm trying to run an arcpy script as a scheduled task, 'out-of-process', and it is not working. Interesting some basic arcpy functions, such as arcpy.Exists(), are working, but most of the functions are not. Also, when I explore into the arcpy folders in C:\Program Files\ArcGIS\Desktop10.2\arcpy\arcpy, many of my python scripts have corresponding compiled version (.pyc). I believe I am pointed to the correct python.exe, as Desktop was installed after Server. Any thoughts on what is happening?
... View more
02-17-2015
01:55 PM
|
0
|
2
|
2710
|
POST
|
I found the same error in our case. Same situation; SDE to FGDB, one-way replica. The tool ran fine from Catalog, but gave me the 582 error when run from a script. I tried reversing the GDBs and it worked fine. For what it's worth, we are at arcsde 10.2.2, on an enterprise SQL 2012.
... View more
01-09-2015
04:59 PM
|
1
|
0
|
1060
|
POST
|
Marianne, is this the basic workflow? 1. Create One-Way Replica 2. Scheduled script that synchronizes the child replica with the parent, e.g. arcpy.SynchronizeChanges_management(SDE, "BackupReplication", GDB, "FROM_GDB1_TO_2")
... View more
12-30-2014
05:48 PM
|
0
|
2
|
2319
|
POST
|
Hello, We have an SDE database on a SQL machine in our MS Server-stack. We would like to run some python/arcpy scripts from this machine as scheduled tasks. We use OS-authentication, and the tasks would be run under a 'Service Account' login. Do we need ArcGIS Desktop installed on that machine in order to call arcpy commands within a script? Some insight: On this machine there is a Python27 folder at the root level, which has one subfolder: ArcGISx6410.2 Thanks, Adam
... View more
12-26-2014
12:35 PM
|
0
|
1
|
4101
|
POST
|
Thank you Jake, Those tools do seem to be the best solution. In our situation, our entire geodatabase is close to 1 gig of data. In my testing, the exported XML file is roughly twice that size, or 1.9 GB, which can pose some issues - Catalog hangs on this file when you click on it e.g. The other option is to iterate through the tables and copy them straight across. Both options work, and your suggestion is definitely the easiest.
... View more
12-26-2014
12:23 PM
|
0
|
2
|
2319
|
POST
|
I need to create a script that will copy our county's parcel data, maintained in SDE/SQL, to a file geodatabase. This script will be run as a scheduled task over the weekend. What GP tool do you recommend for this process? Consider that our schema is 'set in stone' and we have no relationship classes to maintain. I have tested both CopyFeatures_management and FeatureClassToFeatureClass_conversion. Both work. FC to FC is slightly faster, but speed is not really an issue. In theory, CopyFeatures, run with Overwrite = True, matches our workflow as we are not converting to a shapefile or coverage. FeatureClassToGeodatabase_conversion may be the best tool, as there are about 25 feature classes that need to be copied. Also, I need to ensure that the machine running the script is able to connect to the SDE data. We are using DBO-schema with OS authentication. The script will likely be run by the same server that houses our SDE. Does anyone have experience with a similar scenario? Thanks, Adam
... View more
12-20-2014
02:10 PM
|
0
|
9
|
11223
|
POST
|
Does anyone have any experience with PIP, or Pip-Win for installing/managing third-party packages? I would like to utilize 'reportlab', an OSS package for creating PDFs. Currently, my only python interpreter/installation is c:\python27\ArcGIS10.2\. Do I need a separate Python installation to add a package such as reportlab or mathplotlib? My end goal is to utilize reportlab within ArcMap, using a custom script.
... View more
09-23-2014
01:45 PM
|
0
|
1
|
677
|
POST
|
My primary goal will be to create add-ins using Python that include some GUIs. Beyond that, I'm interested in creating some stand alone Python apps and wondering what is the best all around development package. Many Thanks
... View more
04-12-2014
08:39 AM
|
0
|
4
|
3307
|
POST
|
Thanks William, I tried the Copy Rows tool and had some of the same problems. I also tried working with the schema.ini file a little, but didn't have any success. I decided to try using the da.insertCursor and bypass the CSV file. It works. I'm curious to know if anyone out there has a better method for getting these types of files into a gdb table. I'll be working with other files similar to this one, and would prefer not to define the column definitions by hand. I don't have MS Access but am thinking this maybe the best option. Excel won't work because the number of rows is > 65000. Here is the code that worked for me:
import arcpy
input_file = arcpy.GetParameterAsText(0)
geodatabase = arcpy.GetParameterAsText(1)
table_name = arcpy.GetParameterAsText(2)
table_template = arcpy.GetParameterAsText(3)
arcpy.env.workspace = geodatabase
arcpy.env.overwriteOutput = True
arcpy.CreateTable_management(geodatabase,table_name,table_template)
with open(input_file, 'r') as TSGinputfile:
lines = TSGinputfile.readlines()
fields = ('TAXLOT','SNAM','BLK','LOTNO','ACRES','PROPID','STNUM','ADDRANGE','STREET','SDIRPX','STNAM','STYP','SDIRSX',
'SITUSCITY','SITUSZIP','OWNERNAME','OWNERADD','OWNERADD1','OWNERADD2','OWNERADD3','OWNERCITY','OWNERSTATE',
'OWNERZIP','DEEDREF','STCL','LANDVAL','IMPVAL','TOTALVAL','ASSDVAL','ZONING','CODEAREA','PROPCLASS','SALEPRICE',
'SALEDATETXT','SALECODE','YEARCONST','LIVINGAREA','MAINTENANCE','NBRHDCODE','StNumInit','StNumSx','Zip3')
with arcpy.da.InsertCursor(table_name,fields) as cursor:
for line in lines:
PROPID = line[0:8].strip()
TAXLOT = line[8:23].strip()
StNumInit = line[23:34]
StNumSx = line[34:37].strip()
STNAM = line[37:61].strip()
STYP = line[61:63].strip()
SDIRPX = line[63:65].strip()
SDIRSX = line[65:67].strip()
Zip3 = line[67:70].strip()
SNAM = line[70:110].strip()
BLK = line[110:113].strip()
LOTNO = line[113:116].strip()
ACRES = line[116:124].strip()
STCL = line[124:128].strip()
LANDVAL = int(line[128:137].strip())
IMPVAL = int(line[137:146].strip())
TOTALVAL = int(line[146:155].strip())
ASSDVAL = int(line[155:164].strip())
#LastApprDt = line[164:172]
ZONING = line[172:179].strip()
CODEAREA = line[179:187]
#MultCode = line[187:188]
PROPCLASS = line[188:191].strip()
SALEPRICE = int(line[191:200].strip())
SALEDATETXT = line[200:208].strip()
SALECODE = line[208:210].strip()
YEARCONST = int(line[210:214].strip())
LIVINGAREA = int(line[214:219].strip())
OWNERNAME = line[219:251].strip()
OWNERADD1 = line[251:283].strip()
OWNERADD2 = line[283:315].strip()
OWNERADD3 = line[315:347].strip()
OWNERCITY = line[347:363].strip()
OWNERSTATE = line[363:365].strip()
OWNERZIP = line[365:370].strip()
DEEDREF = line[370:381].strip()
MAINTENANCE = line[381:386].strip()
NBRHDCODE = line[386:396].strip()
#CurLeviedTax = line[396:407]
#SALEDATE = validate(SALEDATETXT)
STNUM = 0
ADDRANGE = 0
STREET = ''
SITUSCITY = ''
SITUSZIP = ''
OWNERADD = ''
cursor.insertRow((TAXLOT,SNAM,BLK,LOTNO,ACRES,PROPID,STNUM,ADDRANGE,STREET,SDIRPX,STNAM,STYP,SDIRSX,SITUSCITY,SITUSZIP,
OWNERNAME,OWNERADD,OWNERADD1,OWNERADD2,OWNERADD3,OWNERCITY,OWNERSTATE,OWNERZIP,DEEDREF,STCL,LANDVAL,IMPVAL,
TOTALVAL,ASSDVAL,ZONING,CODEAREA,PROPCLASS,SALEPRICE,SALEDATETXT,SALECODE,YEARCONST,LIVINGAREA,MAINTENANCE,
NBRHDCODE,StNumInit,StNumSx,Zip3))
... View more
03-05-2014
01:01 PM
|
0
|
0
|
982
|
POST
|
Hello, I'm having trouble with schema issues when converting a fixed length text file to a gdb table. My workflow is: 1. convert fixed-length to comma-separated using python's csv module 2. create table from csv file using TableToTable_conversion The original fixed-length file looks like this: R75190 083W05AA03300 00000003268 INDIAN WELLS LP S 302GOLF COURSE ESTATES 00004600000.00R45 00006200000010116000016316000013951011152002 92401000 1010000000000000000000200201402RITCHIE,ADAM S & RITCHIE,TRACEY L 3268 INDIAN WELLS LP S SALEM OR9730222700025BS R581 SSAL.A 00002637.72
R75191 083W05AA03400 00000003264 INDIAN WELLS LP S 302GOLF COURSE ESTATES 00004700000.14R41 00006200000009804000016004000013761011152002 92401000 1010001480000826200300200201340JAMES-BELDEN,DEEDE M 3264 INDIAN WELLS LP S SALEM OR9730221880475WD R581 SSAL.A 00002601.80
R75192 083W05AA03500 00000003258 INDIAN WELLS LP S 302GOLF COURSE ESTATES 00004800000.15R41Z00005730000009363000015093000016652010071997 92401000 1010001299000312199900199701398DUUS,CATHERINE M 3258 INDIAN WELL LOOP S SALEM OR9730215820524WD R581 SSAL.A 00003039.98
R75193 083W05AA03600 00000003254 INDIAN WELLS LP S 302GOLF COURSE ESTATES 00004900000.15R41Z00005730000009363000015093000016652010071997 92401000 1010002180000713200900199701398WALLACE,CONSTANCE M 3254 INDIAN WELLS LP S SALEM OR9730230850148WD R581 SSAL.A 00003039.98
My TXT to CSV code looks like this: import csv, os, datetime, arcpy
workfolder = arcpy.GetParameterAsText(0)
inputfile = arcpy.GetParameterAsText(1)
outfile = arcpy.GetParameterAsText(2)
schemafile = workfolder + '\\schema.ini'
outputfile = workfolder + '\\' + outfile
if os.path.exists(schemafile):
os.remove(schemafile)
if os.path.exists(outputfile):
os.remove(outputfile)
#---------------------------------------------
def validate(date_text):
date_text = date_text.zfill(8)
year = date_text[4:]
month = date_text[0:2]
day = date_text[2:4]
date_sorted = year+month+day
try:
return datetime.datetime.strptime(date_sorted,'%Y%m%d')
except ValueError:
return ""
#----------------------------------------------
with open(outputfile, 'wb') as outcsvfile:
filewriter = csv.writer(outcsvfile,quoting=csv.QUOTE_MINIMAL)
# Add header row
filewriter.writerow(['PropID','Taxlot','StNumInit','StNumSx','StName','StType','StDirPx','StDirSx','Zip3','SubName','Block',
'Lot','Acres','StatClass','RMVLand','RMVImp','RMVTotal','AssdValue','LastApprDt','Zoning','CodeArea','MultCode','PropClass',
'SalePrice','SaleDateTxt','SaleCode','YearConst','LivingArea','OwnerName','OwnerAdd1','OwnerAdd2','OwnerAdd3','OwnerCity',
'OwnerState','OwnerZip','DeedRef','MaintCode','NbrhdCode','TaxBalance','SaleDate'])
# Iterate through file, assign variables and write to CSV file
with open(inputfile, 'r') as TSGinputfile:
for line in TSGinputfile.readlines():
PropID = line[0:8]
Taxlot = line[8:23]
StNumInit = line[23:34]
StNumSx = line[34:37]
StName = line[37:61]
StType = line[61:63]
StDirPx = line[63:65]
StDirSx = line[65:67]
Zip3 = line[67:70]
SubName = line[70:110]
Block = line[110:113]
Lot = line[113:116]
Acres = line[116:124]
StatClass = line[124:128]
RMVLand = line[128:137]
RMVImp = line[137:146]
RMVTotal = line[146:155]
AssdValue = line[155:164]
LastApprDt = line[164:172]
Zoning = line[172:179]
CodeArea = line[179:187]
MultCode = line[187:188]
PropClass = line[188:191]
SalePrice = line[191:200]
SaleDateTxt = line[200:208]
SaleCode = line[208:210]
YearConst = line[210:214]
LivingArea = line[214:219]
OwnerName = line[219:251]
OwnerAdd1 = line[251:283]
OwnerAdd2 = line[283:315]
OwnerAdd3 = line[315:347]
OwnerCity = line[347:363]
OwnerState = line[363:365]
OwnerZip = line[365:370]
DeedRef = line[370:381]
MaintCode = line[381:386]
NbrhdCode = line[386:396]
TaxBalance = line[396:407]
SaleDate = validate(SaleDateTxt)
if Taxlot <> '':
filewriter.writerow([PropID,Taxlot,StNumInit,StNumSx,StName,StType,StDirPx,StDirSx,Zip3,SubName,Block,Lot,Acres,
StatClass,RMVLand,RMVImp,RMVTotal,AssdValue,LastApprDt,Zoning,CodeArea,MultCode,PropClass,SalePrice,SaleDateTxt,
SaleCode,YearConst,LivingArea,OwnerName,OwnerAdd1,OwnerAdd2,OwnerAdd3,OwnerCity,OwnerState,OwnerZip,DeedRef,
MaintCode,NbrhdCode,TaxBalance,SaleDate]) My CSV to Table code looks like this: import arcpy, os
input_csv = arcpy.GetParameterAsText(0)
gdbfolder = arcpy.GetParameterAsText(1)
table_name = arcpy.GetParameterAsText(2)
arcpy.env.workspace = gdbfolder
out_table = os.path.join(gdbfolder,table_name)
if os.path.exists('schemafile.ini'):
os.remove('schemafile.ini')
arcpy.env.overwriteOutput = True
arcpy.TableToTable_conversion(input_csv,gdbfolder,table_name,"#",
"""PropID "PropID" true true false 8 Text 0 0 ,First,#,input_csv,PropID,-1,-1;
Taxlot "Taxlot" true true false 15 Text 0 0 ,First,#,input_csv,Taxlot,-1,-1;
StNumInit "StNumInit" true true false 11 Text 0 0 ,First,#,input_csv,StNumInit,-1,-1;
StNumSx "StNumSx" true true false 3 Text 0 0 ,First,#,input_csv,StNumSx,-1,-1;
StName "StName" true true false 24 Text 0 0 ,First,#,input_csv,StName,-1,-1;
StType "StType" true true false 2 Text 0 0 ,First,#,input_csv,StType,-1,-1;
StDirPx "StDirPx" true true false 2 Text 0 0 ,First,#,input_csv,StDirPx,-1,-1;
StDirSx "StDirSx" true true false 2 Text 0 0 ,First,#,input_csv,StDirSx,-1,-1;
Zip3 "Zip3" true true false 3 Text 0 0 ,First,#,input_csv,Zip3,-1,-1;
SubName "SubName" true true false 40 Text 0 0 ,First,#,input_csv,SubName,-1,-1;
Block "Block" true true false 3 Text 0 0 ,First,#,input_csv,Block,-1,-1;
Lot "Lot" true true false 3 Text 0 0 ,First,#,input_csv,Lot,-1,-1;
Acres "Acres" true true false 8 Double 0 0 ,First,#,input_csv,Acres,-1,-1;
StatClass "StatClass" true true false 4 Text 0 0 ,First,#,input_csv,StatClass,-1,-1;
RMVLand "RMVLand" true true false 4 Long 0 0 ,First,#,input_csv,RMVLand,-1,-1;
RMVImp "RMVImp" true true false 4 Long 0 0 ,First,#,input_csv,RMVImp,-1,-1;
RMVTotal "RMVTotal" true true false 4 Long 0 0 ,First,#,input_csv,RMVTotal,-1,-1;
AssdValue "AssdValue" true true false 4 Long 0 0 ,First,#,input_csv,AssdValue,-1,-1;
LastApprDt "LastApprDt" true true false 8 Text 0 0 ,First,#,input_csv,LastApprDt,-1,-1;
Zoning "Zoning" true true false 7 Text 0 0 ,First,#,input_csv,Zoning,-1,-1;
CodeArea "CodeArea" true true false 8 Text 0 0 ,First,#,input_csv,CodeArea,-1,-1;
MultCode "MultCode" true true false 1 Text 0 0 ,First,#,input_csv,MultCode,-1,-1;
PropClass "PropClass" true true false 3 Text 0 0 ,First,#,input_csv,PropClass,-1,-1;
SalePrice "SalePrice" true true false 4 Long 0 0 ,First,#,input_csv,SalePrice,-1,-1;
SaleDateTxt "SaleDateTxt" true true false 8 Text 0 0 ,First,#,input_csv,SaleDateTxt,-1,-1;
SaleCode "SaleCode" true true false 2 Text 0 0 ,First,#,input_csv,SaleCode,-1,-1;
YearConst "YearConst" true true false 4 Text 0 0 ,First,#,input_csv,YearConst,-1,-1;
LivingArea "LivingArea" true true false 5 Text 0 0 ,First,#,input_csv,LivingArea,-1,-1;
OwnerName "OwnerName" true true false 32 Text 0 0 ,First,#,input_csv,OwnerName,-1,-1;
OwnerAdd1 "OwnerAdd1" true true false 32 Text 0 0 ,First,#,input_csv,OwnerAdd1,-1,-1;
OwnerAdd2 "OwnerAdd2" true true false 32 Text 0 0 ,First,#,input_csv,OwnerAdd2,-1,-1;
OwnerAdd3 "OwnerAdd3" true true false 32 Text 0 0 ,First,#,input_csv,OwnerAdd3,-1,-1;
OwnerCity "OwnerCity" true true false 16 Text 0 0 ,First,#,input_csv,OwnerCity,-1,-1;
OwnerState "OwnerState" true true false 2 Text 0 0 ,First,#,input_csv,OwnerState,-1,-1;
OwnerZip "OwnerZip" true true false 5 Text 0 0 ,First,#,input_csv,OwnerZip,-1,-1;
DeedRef "DeedRef" true true false 11 Text 0 0 ,First,#,input_csv,DeedRef,-1,-1;
MaintCode "MaintCode" true true false 5 Text 0 0 ,First,#,input_csv,MaintCode,-1,-1;
NbrhdCode "NbrhdCode" true true false 10 Text 0 0 ,First,#,input_csv,NbrhdCode,-1,-1;
TaxBalance "TaxBalance" true true false 8 Double 0 0 ,First,#,input_csv,TaxBalance,-1,-1;
SaleDate "SaleDate" true true false 8 Date 0 0 ,First,#,input_csv,SaleDate,-1,-1""","#") The TableToTable tool is not honoring the field mapping I include in the code. For example, OwnerZip is a Long Integer in my output table, and all the text fields are length = 255. One solution I haven't tried yet is to read the input file one line at a time and insert it into a table using an insertCursor. This would bypass the need for a csv file. Any suggestions? Many Thanks, Adam
... View more
03-04-2014
05:35 PM
|
0
|
2
|
1548
|
POST
|
Basically what I would like to do is implement the following TableToTable command using Fieldmappings:
arcpy.TableToTable_conversion(input_csv,gdbfolder,table_name,"#",
"""PropID "PropID" true true false 8 Text 0 0 ,First,#,C:/Workspace/TSGfiles/TSGinfo.csv,PropID,-1,-1;
Taxlot "Taxlot" true true false 15 Text 0 0 ,First,#,C:/Workspace/TSGfiles/TSGinfo.csv,Taxlot,-1,-1;
StreetNo "StreetNo" true true false 11 Text 0 0 ,First,#,C:/Workspace/TSGfiles/TSGinfo.csv,StreetNo,-1,-1;
StreetNoSx "StreetNoSx" true true false 3 Text 0 0 ,First,#,C:/Workspace/TSGfiles/TSGinfo.csv,StreetNoSx,-1,-1;
StreetName "StreetName" true true false 24 Text 0 0 ,First,#,C:/Workspace/TSGfiles/TSGinfo.csv,StreetName,-1,-1;
StreetType "StreetType" true true false 2 Text 0 0 ,First,#,C:/Workspace/TSGfiles/TSGinfo.csv,StreetType,-1,-1;
StreetDirPx "StreetDirPx" true true false 2 Text 0 0 ,First,#,C:/Workspace/TSGfiles/TSGinfo.csv,StreetDirPx,-1,-1;
StreetDirSx "StreetDirSx" true true false 2 Text 0 0 ,First,#,C:/Workspace/TSGfiles/TSGinfo.csv,StreetDirSx,-1,-1;
Zip3 "Zip3" true true false 4 Short 0 3 ,First,#,C:/Workspace/TSGfiles/TSGinfo.csv,Zip3,-1,-1;
SubName "SubName" true true false 40 Text 0 0 ,First,#,C:/Workspace/TSGfiles/TSGinfo.csv,SubName,-1,-1;
Block "Block" true true false 3 Text 0 0 ,First,#,C:/Workspace/TSGfiles/TSGinfo.csv,Block,-1,-1;
Lot "Lot" true true false 3 Text 0 0 ,First,#,C:/Workspace/TSGfiles/TSGinfo.csv,Lot,-1,-1;
Acres "Acres" true true false 8 Double 2 8 ,First,#,C:/Workspace/TSGfiles/TSGinfo.csv,Acres,-1,-1;
StatClass "StatClass" true true false 4 Text 0 0 ,First,#,C:/Workspace/TSGfiles/TSGinfo.csv,StatClass,-1,-1;
RMVLand "RMVLand" true true false 4 Long 0 9 ,First,#,C:/Workspace/TSGfiles/TSGinfo.csv,RMVLand,-1,-1;
RMVImp "RMVImp" true true false 4 Long 0 9 ,First,#,C:/Workspace/TSGfiles/TSGinfo.csv,RMVImp,-1,-1;
RMVTotal "RMVTotal" true true false 4 Long 0 9 ,First,#,C:/Workspace/TSGfiles/TSGinfo.csv,RMVTotal,-1,-1;
AssdValue "AssdValue" true true false 4 Long 0 9 ,First,#,C:/Workspace/TSGfiles/TSGinfo.csv,AssdValue,-1,-1;
LastApprDate "LastApprDate" true true false 8 Text 0 8 ,First,#,C:/Workspace/TSGfiles/TSGinfo.csv,LastApprDate,-1,-1;
Zoning "Zoning" true true false 7 Text 0 0 ,First,#,C:/Workspace/TSGfiles/TSGinfo.csv,Zoning,-1,-1;
CodeArea "CodeArea" true true false 8 Text 0 0 ,First,#,C:/Workspace/TSGfiles/TSGinfo.csv,CodeArea,-1,-1;
MultCodeArea "MultCodeArea" true true false 1 Text 0 0 ,First,#,C:/Workspace/TSGfiles/TSGinfo.csv,MultCodeArea,-1,-1;
PropClass "PropClass" true true false 3 Text 0 0 ,First,#,C:/Workspace/TSGfiles/TSGinfo.csv,PropClass,-1,-1;
SalePrice "SalePrice" true true false 4 Long 0 9 ,First,#,C:/Workspace/TSGfiles/TSGinfo.csv,SalePrice,-1,-1;
SaleDateText "SaleDateText" true true false 8 Text 0 0 ,First,#,C:/Workspace/TSGfiles/TSGinfo.csv,SaleDateText,-1,-1;
SaleCode "SaleCode" true true false 2 Text 0 0 ,First,#,C:/Workspace/TSGfiles/TSGinfo.csv,SaleCode,-1,-1;
YearConst "YearConst" true true false 4 Text 0 0 ,First,#,C:/Workspace/TSGfiles/TSGinfo.csv,YearConst,-1,-1;
GrossLivingArea "GrossLivingArea" true true false 5 Text 0 0 ,First,#,C:/Workspace/TSGfiles/TSGinfo.csv,GrossLivingArea,-1,-1;
OwnerName "OwnerName" true true false 32 Text 0 0 ,First,#,C:/Workspace/TSGfiles/TSGinfo.csv,OwnerName,-1,-1;
OwnerAdd "OwnerAdd" true true false 32 Text 0 0 ,First,#,C:/Workspace/TSGfiles/TSGinfo.csv,OwnerAdd,-1,-1;
OwnerAdd1 "OwnerAdd1" true true false 32 Text 0 0 ,First,#,C:/Workspace/TSGfiles/TSGinfo.csv,OwnerAdd1,-1,-1;
OwnerAdd2 "OwnerAdd2" true true false 32 Text 0 0 ,First,#,C:/Workspace/TSGfiles/TSGinfo.csv,OwnerAdd2,-1,-1;
OwnerCity "OwnerCity" true true false 16 Text 0 0 ,First,#,C:/Workspace/TSGfiles/TSGinfo.csv,OwnerCity,-1,-1;
OwnerState "OwnerState" true true false 2 Text 0 0 ,First,#,C:/Workspace/TSGfiles/TSGinfo.csv,OwnerState,-1,-1;
OwnerZip "OwnerZip" true true false 5 Text 0 0 ,First,#,C:/Workspace/TSGfiles/TSGinfo.csv,OwnerZip,-1,-1;
DeedRef "DeedRef" true true false 11 Text 0 0 ,First,#,C:/Workspace/TSGfiles/TSGinfo.csv,DeedRef,-1,-1;
MaintCode "MaintCode" true true false 5 Text 0 0 ,First,#,C:/Workspace/TSGfiles/TSGinfo.csv,MaintCode,-1,-1;
NbrhdCode "NbrhdCode" true true false 10 Text 0 0 ,First,#,C:/Workspace/TSGfiles/TSGinfo.csv,NbrhdCode,-1,-1;
CurLeviedTax "CurLeviedTax" true true false 8 Double 2 11 ,First,#,C:/Workspace/TSGfiles/TSGinfo.csv,CurLeviedTax,-1,-1;
SaleDate "SaleDate" true true false 8 Date 0 0 ,First,#,C:/Workspace/TSGfiles/TSGinfo.csv,SaleDate,-1,-1""","#")
... View more
02-17-2014
06:24 AM
|
0
|
0
|
479
|
POST
|
Hello, I'm attempting to write a script that takes in a CSV file and utilizes an arcpy.TableToTable_conversion() to create a table in a geodatabase. I would like to take advantage of Field Mapping functionality in arcpy so that I can reliably/consistently create a table with the same attributes. Based on some direction I've found on this forum, I've tried the following code. It creates a table but does not honor the length values of the various string fields (i.e. all string fields are length = 255): def GetFieldMaps():
tblFieldMaps = []
tblFieldMaps.append(["PropID" ,"PropID" ,"String",8])
tblFieldMaps.append(["Taxlot" ,"PropID" ,"String",15])
tblFieldMaps.append(["StreetNo" ,"StreetNo" ,"String",11])
tblFieldMaps.append(["StreetNoSx" ,"StreetNoSx" ,"String",3])
tblFieldMaps.append(["StreetName" ,"StreetName" ,"String",24])
tblFieldMaps.append(["StreetType" ,"StreetType" ,"String",2])
tblFieldMaps.append(["StreetDirPx" ,"StreetDirPx" ,"String",2])
tblFieldMaps.append(["StreetDirSx" ,"StreetDirSx" ,"String",2])
tblFieldMaps.append(["Zip3" ,"Zip3" ,"Short" ,3])
tblFieldMaps.append(["SubName" ,"SubName" ,"String",40])
tblFieldMaps.append(["Block" ,"Block" ,"String",3])
tblFieldMaps.append(["Lot" ,"Lot" ,"String",3])
tblFieldMaps.append(["Acres" ,"Acres" ,"Double",8,2])
tblFieldMaps.append(["StatClass" ,"StatClass" ,"String",4])
tblFieldMaps.append(["RMVLand" ,"RMVLand" ,"Long" ,9])
tblFieldMaps.append(["RMVImp" ,"RMVImp" ,"Long" ,9])
tblFieldMaps.append(["RMVTotal" ,"RMVTotal" ,"Long" ,9])
tblFieldMaps.append(["AssdValue" ,"AssdValue" ,"Long" ,9])
tblFieldMaps.append(["LastApprDate" ,"LastApprDate" ,"String",8])
tblFieldMaps.append(["Zoning" ,"Zoning" ,"String",7])
tblFieldMaps.append(["CodeArea" ,"CodeArea" ,"String",8])
tblFieldMaps.append(["MultCodeArea" ,"MultCodeArea" ,"String",1])
tblFieldMaps.append(["PropClass" ,"PropClass" ,"String",3])
tblFieldMaps.append(["SalePrice" ,"SalePrice" ,"Long" ,9])
tblFieldMaps.append(["SaleDateText" ,"SaleDateText" ,"String",8])
tblFieldMaps.append(["SaleCode" ,"SaleCode" ,"String",2])
tblFieldMaps.append(["YearConst" ,"YearConst" ,"String",4])
tblFieldMaps.append(["GrossLivingArea","GrossLivingArea","String",5])
tblFieldMaps.append(["OwnerName" ,"OwnerName" ,"String",32])
tblFieldMaps.append(["OwnerAdd" ,"OwnerAdd" ,"String",32])
tblFieldMaps.append(["OwnerAdd1" ,"OwnerAdd1" ,"String",32])
tblFieldMaps.append(["OwnerAdd2" ,"OwnerAdd2" ,"String",32])
tblFieldMaps.append(["OwnerCity" ,"OwnerCity" ,"String",16])
tblFieldMaps.append(["OwnerState" ,"OwnerState" ,"String",2])
tblFieldMaps.append(["OwnerZip" ,"OwnerZip" ,"String",5])
tblFieldMaps.append(["DeedRef" ,"DeedRef" ,"String",11])
tblFieldMaps.append(["MaintCode" ,"MaintCode" ,"String",5])
tblFieldMaps.append(["NbrhdCode" ,"NbrhdCode" ,"String",10])
tblFieldMaps.append(["CurLeviedTax" ,"CurLeviedTax" ,"Double",11,2])
tblFieldMaps.append(["SaleDate" ,"SaleDate" ,"Date"])
def GetFieldMappings(out_table,fieldmaplist):
try:
fieldmappings = arcpy.FieldMappings()
for field in fieldmaplist:
fldmap = arcpy.FieldMap()
fldmap.addInputField(out_table,field[0])
fld = fldmap.outputField
fld.name = field[1]
fld.aliasName = field[1]
fld.type = field[2]
fld.length = field[3]
fldmap.outputField = fld
fieldmappings.addFieldMap(fldmap)
print "Added field %s" % (field[1])
return fieldmappings
except Exception as e:
print e
tableFieldMaps = GetFieldMaps()
fieldmappings = GetFieldMappings(out_table,tableFieldMaps)
arcpy.TableToTable_conversion(input_csv,gdbfolder,table_name,fieldmappings)
... View more
02-15-2014
05:49 PM
|
0
|
2
|
1202
|
POST
|
Hello, I am trying to do a similar task: 1. Make a selection_by_attributes on a .gdb Annotation layer. 2. Copy & Paste this selection into an Existing .gdb Annotation layer. Further, I'd like to copy the selected annotation into a specific annotation class within the specified target layer. I am able to do this in an editing session. Is this possible using python? Can you use cursors to copy and paste features from one FC to another? Thanks.
... View more
09-10-2013
01:13 PM
|
0
|
0
|
600
|
POST
|
Hello. I would like to know if the Ground-to-Grid Correction in ArcMap is an object that can be accessed. If so, how? Thanks, Adam
... View more
12-12-2012
08:48 AM
|
0
|
0
|
525
|
Title | Kudos | Posted |
---|---|---|
1 | 04-20-2016 02:41 PM | |
1 | 10-06-2017 02:24 PM | |
2 | 05-25-2018 09:47 AM | |
3 | 10-09-2017 09:29 AM | |
1 | 09-12-2016 12:59 PM |
Online Status |
Offline
|
Date Last Visited |
01-11-2021
06:56 PM
|