POST
|
Insertion order doesn't matter as long as the first item creates the table while the remaining items append to it. Not entirely sure what you mean by code snippets and what comes after but I do some analysis work after I start the iteration through the dictionary using network analysis and the last step in the iteration is what this thread is for, either creating the table or appending to it and then repeating the steps. Hope that helps.
... View more
05-16-2018
06:42 AM
|
0
|
4
|
560
|
POST
|
Apparently the append worked this time around but the original data was overwritten with the data that was appended. I think the issue lies with how the if statement is set up in the for loop. How would you set it up?
... View more
05-15-2018
01:18 PM
|
0
|
6
|
1298
|
POST
|
So hubDict is actually a dictionary. To loop over over it, I'm doing the following: for hub in hubDict:
valueHub = dict.get(hubDict, hub)
hubQuery = "HubName = " + "'" + str(valueHub) + "'"
nodeQuery = "ProjectHub = " + "'" + str(valueHub) + "'"
hubLayer.definitionQuery = hubQuery
nodeLayer.definitionQuery = nodeQuery hubLayer and nodeLayer are variables that point to the hub and node layers in my data frame. After this, in the loop I do a network analysis and use that to do some joins and run a summary statistics. I'm trying to use the output table from the summary statistics to get into the results FGDB.
... View more
05-15-2018
12:31 PM
|
0
|
0
|
1298
|
POST
|
When I run the steps outside of the main for loop, the append is being executed correctly. My issue is not sure how to script it for the script to read it as the first iteration or Xth iteration. I want the first iteration to create the table and the following iterations to be appended to it.
... View more
05-15-2018
11:56 AM
|
0
|
9
|
1298
|
POST
|
It's not being executed because of the else statement. I don't think I set that up correctly nor do I know how to fix that. For some reason that is not registering on the second iteration and would love it if you have any ideas on how to approach this scenario..
... View more
05-15-2018
11:01 AM
|
0
|
0
|
1298
|
POST
|
Hi Joshua, Sorry about the delay in getting back to you. So my script first creates a dictionary per feature in a feature class. Then the script runs a for loop per feature in the feature class using the values in the dictionary. Rather than exporting several tables and their excel sheets, I am trying to create a table with the first iteration using table to table (conversion) and then for the rest of the iterations, I want their tables to append to the created table from the first iteration. The way I have it set up is the following: if hubDict[0]:
in_rows = 'table'
out_path = folderPath + '/' + 'Results.gdb'
out_name = 'Results'
arcpy.TableToTable_conversion(in_rows, out_path, out_name)
else:
inputs = 'table'
target = folderPath + '/' + 'Results.gdb' + '/' + 'Results'
arcpy.Append_management(inputs, target, "NO_TEST") The Results table is being created on the first iteration but on the second one, the data isn't getting appended.
... View more
05-15-2018
10:19 AM
|
0
|
12
|
1298
|
POST
|
Hello, I am working with a for loop where a summary statistics is created. I am able to store the output to a custom file gdb using TableToTable conversion. However, I'm not able to append data to it on the following iterations. How can I go about this? if hubDict[0]:
arcpy.TableToTable_conversion(in_rows, out_path, out_name)
else:
arcpy.Append_management(inputs, target, "NO_TEST")
hubDict is a dictionary i have created earlier on. in_rows, out_path, out_name, inputs, target are all variables that are defined to the correct files and output locations.
... View more
05-10-2018
11:16 AM
|
0
|
14
|
2033
|
POST
|
Steve, Here is the output of that. I'm not seeing anything different other than the location. Location of the output shouldn't matter. And my stats field and case field are the same. arcpy.Statistics_analysis(in_table="Slack Features", out_table="C:/Users/vshah/Documents/ArcGIS/Default.gdb/DBO_Statistics5", statistics_fields="footage SUM", case_field="NetworkID;ProjectID;type")
... View more
04-11-2018
01:04 PM
|
0
|
0
|
1450
|
POST
|
Edit at the bottom. So I am creating a script tool to be able to provide reports on a weekly basis without having to enter in the parameters over and over again where as I can just click a button to run it for me in the form of a script tool. Here's what my script looks like: import arcpy
import os
import arcpy.mapping as map
from arcpy import env
import datetime
mxd = arcpy.mapping.MapDocument("Current")
slackFeatures = r'Slack Features'
date = datetime.date.today()
reportsGDB = r'\\Desktop\Summary_Report\Slack_Summary_Reports.gdb'
reportsFolder = r'\\Desktop\Summary_Reports'
inLayer = slackFeatures
outputName = 'slack_summary'
outLayer = reportsGDB + "/" + outputName
statsFields = ["footage", "SUM"]
caseFields = ["NetworkID", "ProjectID", "type"]
arcpy.Statistics_analysis(inLayer, outLayer, statsFields, caseFields) This gives me the Error 000800: The value is not a member of SUM | MEAN | MIN | MAX | RANGE | STD | COUNT | FIRST | LAST. Inputting these parameters manually into the Summary Statistics tool works but it doesn't in the script. I am currently out of ideas to solve this and am open to ideas to try out. The field footage is a Long field and works manually in the Summary Statistics tool but does not work in the script. I tried the summary statistics tool on another feature class and the custom fields we have in that are Double which the summary statistics works fine for in the script. I tried it on a Long field again for the feature class with the custom fields and the summary statistics throws back the same error. Why the Summary Statistics tool not work in a script for Long fields but would work for Double fields?
... View more
04-11-2018
09:21 AM
|
0
|
4
|
2064
|
POST
|
I didn't even think of the first way you had it set up. What I used was this: hubFeatures = r'hub_locations'
hubDict = {}
with arcpy.da.SearchCursor(hubFeatures, 'HubName') as cursor:
for enum, row in enumerate(cursor):
hubDict[enum] = row[0]
for hub in hubDict:
valueHub = dict.get(hubDict, hub)
hubQuery = "NAME = " + "'" + str(valueHub) + "'"
hubLayer = arcpy.mapping.ListLayers(mxd, 'hub_locations')[0]
hubLayer.definitionQuery = hubQuery
... View more
03-29-2018
09:57 AM
|
0
|
1
|
549
|
POST
|
Awesome and that doesn't interfere with my definition query that I am applying afterwards. Thank you so much for your help Blake!
... View more
03-29-2018
08:38 AM
|
0
|
3
|
549
|
POST
|
Blake that seems to get it in the format I want it in. Do you know why the u appears before the value from the NAME field? {0: u'Hub Name'}
... View more
03-29-2018
08:14 AM
|
0
|
7
|
5263
|
POST
|
I did. While it does create a dictionary and populates it with a value, the NAME field value becomes the key and the value portion is empty. I'm trying to make it where the key is a numeric integer and the NAME field value is the value in the dictionary. hubFeatures = r'hub_locations'
fieldList = "NAME"
hubDict = {r[0]:(r[1:]) for r in arcpy.da.SearchCursor(hubFeatures, fieldList)} using: print hubDict I get: {u'Hub Name': ()} My desired output: {1: 'Hub Name'} How do I get to that? Reason I want to get that to be the output is because I want to use this for applying queries before doing the core function of the tool, which is conducting a network analysis.
... View more
03-29-2018
08:00 AM
|
0
|
0
|
5263
|
Title | Kudos | Posted |
---|---|---|
1 | 07-26-2018 09:12 AM | |
1 | 07-18-2017 01:12 PM | |
1 | 03-09-2017 09:57 AM | |
2 | 03-22-2018 09:49 AM | |
1 | 09-19-2017 01:18 PM |