This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
l1_name = [] | |
with arcpy.da.SearchCursor(r"layer1", ("OID@", "Name")) as cursor: | |
for row in cursor: | |
l1_name.append(row[1]) | |
l2_name = [] | |
with arcpy.da.SearchCursor(r"layer2", ("OID@", "Name")) as cursor2: | |
for row in cursor2: | |
l2_name.append(row[1]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# puts all file paths in filelist | |
# puts all folders in dirlist | |
filelist = [] | |
dirlist = [] | |
for (dirpath,dirnames,filenames) in os.walk('my\path\to\walk'): | |
filelist += [os.path.join(dirpath,file) for file in filenames] | |
dirlist += dirnames |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# fm_input is a field mapping tuple | |
# fm_input = (("target1","source1"),("target2","source2"),("target3","source3")) | |
def build_field_map(target, source, fm_input): | |
field_mapps = arcpy.FieldMappings() | |
field_mapps.addTable(target) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def expression_from_cal(infile): | |
with open(infile, "rb") as data: | |
text = data.read().decode('utf-16-le') | |
print_msg(text) | |
return text.strip() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def expression_code_block_from_cal(infile): | |
with open(infile, "rb") as data: | |
text = data.read().decode('utf-16-le') | |
lines = text.splitlines() | |
# trim the trailing spaces |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Source: http://gis.stackexchange.com/questions/54804/fastest-methods-for-modifying-attribute-tables-with-python | |
# fc - is the full path name to table or feature class | |
def make_attribute_dict(fc, key_field, attr_list=['*']): | |
attdict = {} | |
fc_field_objects = arcpy.ListFields(fc) | |
fc_fields = [field.name for field in fc_field_objects if field.type != 'Geometry'] | |
if attr_list == ['*']: | |
valid_fields = fc_fields | |
else: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=IF(ISERROR(FIND("\",A2)),A2, RIGHT(A2,LEN(A2) - FIND("|",SUBSTITUTE(A2,"\","|",LEN(A2)-LEN(SUBSTITUTE(A2,"\","")))))) |