|
POST
|
Joe, Same result. I put the question to stack exchange, where they often like to do a lot of nagging rather than helping. From what they were saying, though, I guess it's repeating because the outer loop loops once for each variable and then loops for each variable again for the inner loop. So, I guess that sort of draws out my main problem--I'm wondering how to use a list as a means to have one variable in the arcpy.FeatureClassToFeatureClass_conversion() function instead of repeating the block of code for each variable, basically. This wasn't ,my original question, so maybe I should post an additional one.
... View more
03-05-2018
01:01 PM
|
0
|
2
|
3584
|
|
POST
|
When I run it in regular mode both print statements are printed twice. I've attempted to use break after the for statements, but then it only runs the loop enough to print one of the two variables. I also tried to exit the loop with continue and pass, which didn't do anything.
... View more
03-05-2018
09:22 AM
|
0
|
4
|
3584
|
|
POST
|
That worked great, thanks. I adapted it to save two files as you can see in the variables, and it works fine. However, after running the debugger on it I noticed it's looping through the whole thing numerous times and taking longer than it should to complete. Maybe you can spot why that is? import arcpy
arcpy.env.overwriteOutput = True
# full path to connection file:
infeatures = ([r'Database Connections\Jared to Plainfield.sde\gisedit.DBO.MGU_Will\gisedit.DBO.Street',
r'Database Connections\Jared to Plainfield.sde\gisedit.DBO.MGU_Will\gisedit.DBO.Address_Points'])
outpath = r'\\gisfile\GISstaff\Jared\Test'
outfeatures = ['WillCounty_Streets', 'WillCounty_AddressPoints']
for infs in infeatures:
print infs
for otfs in outfeatures:
arcpy.FeatureClassToFeatureClass_conversion(infs,outpath,otfs)
print otfs
... View more
03-05-2018
08:15 AM
|
0
|
6
|
3584
|
|
POST
|
Is there a way using arcpy to grab feature classes directly from an SDE and copy to a folder? I have a real chunky way to do it, namely using these functions: arcpy.mapping.ListDataFrames()
arcpy.mapping.ListLayers()
arcpy.mapping.AddLayer()
arcpy.FeatureClassToFeatureClass_conversion()
The script overall adds features from an SDE to an mxd then saves them as shapefiles in a folder. How can I avoid using the mxd as a sort of springboard?
... View more
03-02-2018
02:36 PM
|
0
|
9
|
4060
|
|
POST
|
Found out Open Data supports the following file types: map services feature services image services CSVs PDFs & Word docs
... View more
03-01-2018
07:49 AM
|
1
|
0
|
816
|
|
POST
|
Are the Data Categories restricted to a certain data type when using the Tag Query? I've added the tag Transportation to a few feature services in AGOL. I then added the same tag here in the Tag Query box. But, after clicking on this Data Category link in the website for testing I only get one result. I was expecting all the feature services to be there. I'm not sure what's going on.
... View more
02-28-2018
01:21 PM
|
0
|
1
|
1009
|
|
POST
|
I have the same problem, basically. I gave a few feature services the same tag in AGOL. Then in our Open Data Editor, in the Tag Query box, I put the same tag. When viewing the website I only see one result when there should be a few? I made sure the tags were spelled correctly and the data is set to view publicly. Do the Data Categories in Open Data only allow you to tag certain data types?
... View more
02-28-2018
12:36 PM
|
0
|
1
|
1997
|
|
POST
|
Thanks everybody. While Matthew's renaming link was pretty much what I was looking for I decided to go with Blake's version as it was right here and works great.
... View more
02-08-2018
06:52 AM
|
0
|
0
|
5485
|
|
POST
|
Matthew, EDIT: You answered my question, and that worked to name it correctly, but I still have a problem. I wasn't very clear but I actually want a script to put the date on existing zipfiles, this one being one of them in a folder full of them. I'm not sure if the write method is even what I should be doing.
... View more
02-07-2018
01:38 PM
|
0
|
1
|
5485
|
|
POST
|
Using PythonWin 2.7.10, I would like to append a date to a bunch of zipfiles in a folder. I've been using the time module which prints the current month, day and year. But, I'm not sure how to append this date to the end of my zipfiles' file name. In this case I've been running tests on the WillCounty_PLSS.zip file, which contains a shapefile. This script seems to work, but it creates an odd looking file with no content: import time
import arcpy
from arcpy import env
ws = arcpy.env.workspace = r'\\gisfile\GISstaff\Jared'
current_time = time.strftime("%m%d%Y")
output_name = "WillCounty_PLSS.zip" + current_time
output_file = open(ws + output_name, "w")
print current_time Here's how the file was named: JaredWillCounty_PLSS.zip02072018 EDIT: What do I need to do to have the look like this: WillCounty_PLSS_02072018.zip?
... View more
02-07-2018
12:59 PM
|
0
|
7
|
5950
|
|
POST
|
Thanks both Dan and Randy. That was the solution. Interestingly, what you have there works to order the fields in a descending order. On the other hand, the only way I got them to order in ascending order was not to have anything after ...ContestTitle: for rows in arcpy.da.SearchCursor(intable, field, sql_clause=(None, "ORDER BY ContestTitle")): I tried "ORDER BY ContestTitle ASCE" and it threw an errror.
... View more
01-31-2018
11:50 AM
|
0
|
1
|
7927
|
|
POST
|
Using arcpy.da.SearchCursor, how do you sort data in either ascending or descending order? I noticed the old arcpy.SearchCursor had sort_fields. arcpy.SearchCursor(dataset, {where_clause}, {spatial_reference}, {fields}, {sort_fields}) I have a script that uses arcpy.da.SearchCursor to create a list of table fields. The "D" in the function of line 8 is meant to put it in descending order, but it does not. env.workspace = r'\\gisfile\GISstaff\Jared\ModelBuilder\TEST folder\TESTGDB.gdb'
#variables
intable = "ElectionResults_Nov2016"
tbList = [] #create list
#use cursor to get all unique values in field, and list them in ascending order
for row in arcpy.da.SearchCursor(intable, "ContestTitle", "D"):
if row[0] not in tbList:
tbList.append(row[0]) EDIT: I've also been looking into sorted. It's a matter of placing it in the cursor, though. sorted()
... View more
01-31-2018
08:02 AM
|
0
|
4
|
11138
|
|
POST
|
Randy, It works pretty flawlessly, thanks! Could you briefly explain how the dictionary works in this script? tbList = []
... View more
01-29-2018
07:39 AM
|
0
|
1
|
2289
|
|
POST
|
Randy, Thanks for the help. All options are great. I went with the last one. I copied the script verbatim and it wrote new tables successfully except for one table, Results31. It's hung up. I did a few things to troubleshoot this: closed everything, used the 'ElectionResults_Nov2016' file in a different workspace, made sure the 'STATES ATTORNEY' record was even there... Traceback (most recent call last):
File "C:\Python27\ArcGIS10.4\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 326, in RunScript
exec codeObject in __main__.__dict__
File "\\gisfile\GISstaff\Jared\Python Scripts\Test2.py", line 22, in <module>
arcpy.TableSelect_analysis(intable, v, where_clause)
File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\analysis.py", line 145, in TableSelect
raise e
ExecuteError: ERROR 999999: Error executing function.
An invalid SQL statement was used.
An invalid SQL statement was used. [ElectionResults_Nov2016]
An invalid SQL statement was used. [SELECT * FROM ElectionResults_Nov2016 WHERE ContestTitle = 'STATE'S ATTORNEY ']
The table was not found. [Results31]
Failed to execute (TableSelect). **EDIT: the 'STATE'S ATTORNEY' record is the only one with an apostrophe. So, I'm guessing this may be a format issue. I'm attempting to use the substitution function to get rid of it. import re
re.sub() Also, instead of naming the new tables 'Results' how would you give them the table record's name?
... View more
01-25-2018
12:22 PM
|
0
|
4
|
2289
|
|
POST
|
TableSelect_analysis(in_table, out_table, {where_clause}) "Selects table records matching a Structured Query Language (SQL) expression and writes them to an output table." Using this function I have this simple script: import arcpy
from arcpy import env
env.workspace = r'\\gisfile\GISstaff\Jared\ModelBuilder\JaredTest.gdb'
#variables
intable = r"\\gisfile\GISstaff\Jared\ModelBuilder\JaredTest.gdb\ElectionResults_Nov2016"
outtable = r"\\gisfile\GISstaff\Jared\ModelBuilder\JaredTest.gdb\Results3"
where_clause = "ContestTitle = 'BALLOTS CAST - TOTAL'"
arcpy.TableSelect_analysis(intable, outtable, where_clause) It selects all records named 'BALLOTS CAST - TOTAL' from the 'ContestTitle' column of my 'ElectionResults_Nov2016' table and writes them in the newly created 'Results3' table. 'BALLOTS CAST - TOTAL' is only one of 58 separate table record names. How can I write all 58 to their own tables? Thanks for any help.
... View more
01-19-2018
11:50 AM
|
0
|
7
|
2565
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 11-13-2025 08:22 AM | |
| 1 | 11-12-2025 08:37 AM | |
| 1 | 10-22-2025 02:14 PM | |
| 1 | 01-17-2019 08:21 AM | |
| 1 | 07-06-2023 07:08 AM |
| Online Status |
Offline
|
| Date Last Visited |
Friday
|