POST
|
Hi all, I'm trying to re-write this to run through SQL Server for performance reasons. Here is what I have, but it is not generating the sequence from 1 to n, it is starting at the row number of the PARTITION_BY and GROUP_BY statement. UPDATE CPTESTPOINTINSPECTION
SET CPTESTPOINTINSPECTION.SEQ_NO = seq
FROM
(
SELECT t.TECH_ID,i.GAS_CORR_STRUCT_NO, INSPECTIONDATE, SEQ_NO, ROW_NUMBER() OVER (PARTITION BY t.TECH_ID ORDER BY i.GAS_CORR_STRUCT_NO) AS Seq
FROM ASSIGNED_TECHS t
INNER JOIN GISDG..CONVERSION.CPTESTPOINTINSPECTION i
ON i.ASSIGNED_USER = t.TECH_ID
) CPTESTPOINTINSPECTION
WHERE CPTESTPOINTINSPECTION.INSPECTIONDATE IS NULL I know this isn't a SQL forum but I figured I'd ask anyway, I know there are very talented people here, so I figured I'd give it a shot.
... View more
04-12-2013
05:46 AM
|
0
|
0
|
1494
|
POST
|
Thank you Matt, using a dictionary worked well: lookupDict = {}
searchRows = arcpy.SearchCursor(psegGasGDB_InputPrefix + "ASSIGNED_TECHS")
searchRow = searchRows.next()
while searchRow:
lookupDict[searchRow.TECH_ID] = [searchRow.TECH_ID]
where_clause = """ "ASSIGNED_USER" = """ + "'"+searchRow.TECH_ID+"'"
updatecursor = arcpy.UpdateCursor(CONVERSION_InputPrefix + "CPTestPointInspection", where_clause, "", "SEQ_NO; GAS_CORR_STRUCT_NO", "GAS_CORR_STRUCT_NO")
stop = 0
fldSEQNO = "SEQ_NO"
for row in updatecursor:
try:
print stop
stop = stop + 1
row.setValue(fldSEQNO, stop)
cursor.updateRow(row)
except Exception as e:
print e
logging.error(": %s" %(e))
searchRow = searchRows.next()
del searchRow
del searchRows
... View more
09-05-2012
07:32 AM
|
0
|
0
|
1494
|
POST
|
Hello, I'm trying to use an UpdateCursor inside of a SearchCursor to populate sequence numbers on an inspection table according to a parcitular UserID. Basically the SearchCursor iterates through a small table with a list of about 29 user ID's (the table changes over time) and uses the values in the where_clause of the updatecursor. The UpdateCursor sorts the order of the input table based on a structure number and populates the sequences from 1 to 0. Here is the code I have tried: techrows = arcpy.SearchCursor(psegGasGDB_InputPrefix + "ASSIGNED_TECHS") for row in techrows: if TechID != row.ASSIGNED_USER: TechID = row.ASSIGNED_USER where_clause = "ASSIGNED_USER = " + TechID rows = arcpy.UpdateCursor(CONVERSION_InputPrefix + "CPTestPointInspection", where_clause, "SEQ_NO; GAS_CORR_STRUCT_NO", "GAS_CORR_STRUCT_NO") for row in rows: try: print row stop = 1 row.SetValue("SEQ_NO", stop) stop = stop + 1 except Exception as e: print e logging.error(": %s" %(e)) del rows del techrows But this gives an "Error 999999: Index passed was not within the valid range". Can't figure out what I'm doing wrong...
... View more
08-30-2012
11:30 AM
|
0
|
5
|
3724
|
POST
|
I need to be able to create a selection on a layer in AGS (preferably with a select by lasso tool) and subsequently click a button that will access a model that assigns inspection assignments through network analyst on the selection. I can't figure out how to add the option for these tools...any help? Very new to AGS. Thanks.
... View more
08-20-2012
06:45 AM
|
0
|
0
|
468
|
POST
|
This actually proved so time-consuming I just did a complete workaround by having the table created in a separate SQL statement that is executed from the command line. Much simpler. Thanks for the assistance though, Kim.
... View more
08-08-2012
10:55 AM
|
0
|
0
|
447
|
POST
|
I'm trying to copy feature from one feature class to another with only certain fields and an SQL query. I can't seem to get the field mappings object to work right. Here is what I have: import arcpy from arcpy import env arcpy.env.overwriteOutput = True in_path =r"Database Connections/Sun120 - 5151.sde/CONVERSION." in_feature = "CPTESTPOINTINSPECTION" out_path = r"E:/Rich Anderson/CP_ReChecks/" FileGDBName = "Test.gdb" infc1 = in_path + in_feature try: fieldmappings = arcpy.FieldMappings() fieldmappings.addTable(infc1) fldmap_READING = arcpy.FieldMap() fldmap_READING.addInputField(infc1, "READING") fld_READING = fldmap_READING.outputField fld_READING.name = "READING" fldmap_READING.outputField = fld_READING fieldmappings.addFieldMap(fldmap_READING) arcpy.FeatureClassToFeatureClass_conversion(in_path + in_feature, out_path + FileGDBName, "Max_CP_Inspection_Date_Test", " \"READING\" > 85 ", fieldmappings) except Exception as e: print e This works but just adds a new field called "READING_1" with all null values to the output feature class along with all of the other fields (including the original "READING" field and its values). How can I get the feature class to feature class tool to only copy the fields I want? I've been at this for over four hours! Thanks...
... View more
08-06-2012
07:43 AM
|
0
|
2
|
1320
|
POST
|
I am modifying a model that creates a route for a selection of points, assigns a USER ID from an input box and a sequence number. I need to make a check box that asks if the user would like to solve the route. If the box is not checked, the route is not solved and only the USER ID will be populated, and the sequence number will not be assigned. I have the boolean variable set as a parameter and the model works when it is checked, but when it is unchecked the model will not run. How do I tell the model to skip the solve process and calculation of the sequence number field and move directly to calculating the user ID? [ATTACH=CONFIG]16433[/ATTACH]
... View more
07-27-2012
04:47 AM
|
0
|
1
|
1626
|
POST
|
Thank you for your suggestion Solomon. I tried setting up a separate boolean variable as a parameter on the calculate field tool for the LANID, but it did not work. The LANID gets populated but the sequence number remains null even though the route was calculated. [ATTACH=CONFIG]16431[/ATTACH] Does anyone have any idea how to make this work? It seems like it shouldn't be so difficult...
... View more
07-27-2012
04:02 AM
|
0
|
0
|
676
|
POST
|
I am modifying a model that creates a route for a selection of points, assigns a USER ID from an input box and a sequence number. I need to make a check box that asks if the user would like to solve the route. If the box is not checked, the route is not solved and only the USER ID will be populated, and the sequence number will not be assigned. I have the boolean variable set as a parameter and the model works when it is checked, but when it is unchecked the model will not run. How do I tell the model to skip the solve process and calculation of the sequence number field and move directly to calculating the user ID? [ATTACH=CONFIG]16379[/ATTACH]
... View more
07-25-2012
05:25 AM
|
0
|
3
|
1051
|
POST
|
I got it, was actually quite simple: import smtplib import datetime import logging HOST = "mailhost.xxxx.com" PORT = 25 from_addr = r"xxxx.xxxxxxx@xxxx.com" to_addr = r"xxxx.xxxxxxx@xxxx.com" subj = "ArcServer Update Script" date = datetime.datetime.now().strftime( "%d/%m/%Y %H:%M" ) message_text = "Hello\nThis is a mail from your server\n\nBye\n" msg = "From: %s\nTo: %s\nSubject: %s\nDate: %s\n\n%s" % ( from_addr, to_addr, subj, date, message_text ) try: test = "test" smtp = smtplib.SMTP(HOST, PORT) smtp.sendmail(from_addr,to_addr,msg + "%s" %(test)) smtp.quit() except Exception as e: print e logging.error(": %s" %(e))
... View more
07-20-2012
11:17 AM
|
0
|
0
|
2312
|
POST
|
Yes set the coordinate system of the buildings the same as the boundaries. To get the code to work, leave the Pre-logic script code the same and set the "Shape =" box to: XYsetVALUE ( !SHAPE!, !POINT_X!, !POINT_Y! )
... View more
07-18-2012
04:18 AM
|
0
|
0
|
437
|
POST
|
The file geodatabase exists solely for this purpose and should not have any other locks on it.
... View more
07-18-2012
04:14 AM
|
0
|
0
|
483
|
POST
|
I'm running Python 2.6.5. Yes this will be part of a script that updates a File Geodatabase automatically used by ArcServer as a feature landbase. I want the email to send to myself and another individual when the process succeeds or fails. manhunter trying to run that throws ImportError: No module named mah.wxDialogs Thanks I appreciate the help.
... View more
07-18-2012
04:12 AM
|
0
|
0
|
2312
|
POST
|
I am trying to get this to work: import smtplib
from smtplib import SMTP_SSL as SMTP
import datetime
HOST = "xxxxxxxx.enterprise.xxxx.com"
PORT = 25
FROM = "xxxx.xxxxxxxx@xxxx.com"
TO = ["xxxx.xxxxxxxxx@xxxx.com"]
SUBJECT = "Test"
BODY = "Success"
BODY = BODY + "!"
smtp = smtplib.SMTP(HOST,PORT)
smtp.connect(HOST, PORT)
smtp.login("xxxxxx\xxxxx", "xxxxx")
smtp.ehlo()
smtp.sendmail(FROM,TO,body)
smtp.quit()
server.set_debuglevel(0) But I keep getting the following error: [Errno 10054] An existing connection was forcibly closed by the remote host Can't see anything obvious I'm doing wrong. Any ideas? Thanks.
... View more
07-17-2012
06:27 AM
|
0
|
5
|
8650
|
Title | Kudos | Posted |
---|---|---|
1 | 02-18-2014 07:08 AM | |
1 | 02-27-2014 05:22 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|