Parentheses Rules

799
8
Jump to solution
02-06-2012 05:30 AM
NathanBaylot1
New Contributor
import arcpy ## Workspace ## FIPS = "C:\\Users\\D2148\\Documents\\Maps\\FIPS"   #FIPSlist = ('001', '003', '005', '007', '009', '011', '013',   #       '015', '017', '019', '021', '023', '025', '027',   #      '029', '031', '033', '035', '037', '039', '041',    #     '043', '045', '047', '049', '051', '053', '055',     #    '057', '059', '061', '063', '065', '067', '069',      #   '071', '073', '075', '077', '079', '081', '083',       #  '085', '087', '089', '091', '093', '095', '097',        # '099', '101', '103', '105', '107', '109', '111',         #'113', '115', '117', '119', '121', '123', '125',         #'127')         FIPSlist = '001'  ###### CLEAR SELECTION FIRST ######## for fip in FIPSlist:      ## SQL for "Master_TAHI" ##     query = "FIPS_PARIS ='" + fip + "'"      ## SQL for "All_roads_cityjoin" ##   query2 = "Parish_FIP ='" + fip + "'"      ## Create FIPS###.dbf from Master_TAHI ##   arcpy.TableSelect_analysis("Master_TAHI", FIPS + "\\FIPS" + fip + ".dbf",query)      ## Create AllRoadsParish###.shp from All_roads_cityjoin ##   arcpy.Select_analysis("All_roads_cityjoin",FIPS + "\\AllRoadsParish" + fip + ".shp",query2)        ## Create Address Locator ##   Output_Address_Locator = "C:\\Users\\D2148\\Documents\\Maps\\FIPS\\add" + fip       arcpy.CreateAddressLocator_geocoding("US Address - Street Name", "AllRoadsParish" + fip 'Primary Table'", "'Feature ID' OBJECTID VISIBLE NONE;'Prefix Direction' PREFIX VISIBLE NONE;'Prefix Type' <None> VISIBLE NONE;'*Street Name' NAME VISIBLE NONE;'Suffix Type' Street_Cat VISIBLE NONE;'Suffix Direction' SUFFIX VISIBLE NONE;'Left City or Place' <None> VISIBLE NONE;'Right City or Place' <None> VISIBLE NONE;'Left ZIP Code' ZIPL VISIBLE NONE;'Right ZIP Code' ZIPR VISIBLE NONE;'Left State' STATE VISIBLE NONE;'Right State' STATE VISIBLE NONE;'Left Additional Field' Parish_FIP VISIBLE NONE;'Right Additional Field' Parish_FIP VISIBLE NONE", Output_Address_Locator, "")      

These stupid parentheses keep making me so mad.... Are there rules as how to place parentheses? I can't get this code to work, there is a syntax error on this part.
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
MathewCoyle
Frequent Contributor
Ah that is because you don't have a space in your script, like this.

"AllRoadsParish" + fip +" 'Primary Table'"

View solution in original post

0 Kudos
8 Replies
MathewCoyle
Frequent Contributor
I think you mean the quotation marks?

Your line should look like this
arcpy.CreateAddressLocator_geocoding("US Address - Street Name", "AllRoadsParish" + fip +"'Primary Table'", "'Feature ID' OBJECTID VISIBLE NONE;'Prefix Direction' PREFIX VISIBLE NONE;'Prefix Type' <None> VISIBLE NONE;'*Street Name' NAME VISIBLE NONE;'Suffix Type' Street_Cat VISIBLE NONE;'Suffix Direction' SUFFIX VISIBLE NONE;'Left City or Place' <None> VISIBLE NONE;'Right City or Place' <None> VISIBLE NONE;'Left ZIP Code' ZIPL VISIBLE NONE;'Right ZIP Code' ZIPR VISIBLE NONE;'Left State' STATE VISIBLE NONE;'Right State' STATE VISIBLE NONE;'Left Additional Field' Parish_FIP VISIBLE NONE;'Right Additional Field' Parish_FIP VISIBLE NONE", Output_Address_Locator, "")
0 Kudos
NathanBaylot1
New Contributor
and yes I did mean quotes lol thanks
0 Kudos
NathanBaylot1
New Contributor
Those quotes are even messing with my mind!
0 Kudos
NathanBaylot1
New Contributor
I get this error now.
Runtime error <class 'arcgisscripting.ExecuteError'>: ERROR 000039: Not enough reference data tables for this style.
I edited like you said and the .shp and .dbf were created correctly, just the create address locator didn't work.
0 Kudos
MathewCoyle
Frequent Contributor
0 Kudos
NathanBaylot1
New Contributor
well what I did was hardcode the
"AllRoadsParish001 'Primary Table'"

into the address locator script and it worked. But, if I put the

"AllRoadsParish" + fip + "'Primary Table'"

in there it will not
0 Kudos
MathewCoyle
Frequent Contributor
Ah that is because you don't have a space in your script, like this.

"AllRoadsParish" + fip +" 'Primary Table'"
0 Kudos
NathanBaylot1
New Contributor
See told you those quotes are nasty.... Yeah it worked thanks!

import arcpy
## Workspace ##
FIPS = "C:\\Users\\D2148\\Documents\\Maps\\FIPS"
 
#FIPSlist = ('001', '003', '005', '007', '009', '011', '013', 
 #       '015', '017', '019', '021', '023', '025', '027',
  #      '029', '031', '033', '035', '037', '039', '041',
   #     '043', '045', '047', '049', '051', '053', '055',
    #    '057', '059', '061', '063', '065', '067', '069',
     #   '071', '073', '075', '077', '079', '081', '083',
      #  '085', '087', '089', '091', '093', '095', '097',
       # '099', '101', '103', '105', '107', '109', '111',
        #'113', '115', '117', '119', '121', '123', '125',
        #'127')
       
FIPSlist = ('001', '003')

###### CLEAR SELECTION FIRST ########
for fip in FIPSlist:
  
  ## SQL for "Master_TAHI" ##  
  query = "FIPS_PARIS ='" + fip + "'"
  
  ## SQL for "All_roads_cityjoin" ##
  query2 = "Parish_FIP ='" + fip + "'"
  
  ## Create FIPS###.dbf from Master_TAHI ##
  arcpy.TableSelect_analysis("Master_TAHI", FIPS + "\\FIPS" + fip + ".dbf",query)
  
  ## Create AllRoadsParish###.shp from All_roads_cityjoin ##
  arcpy.Select_analysis("All_roads_cityjoin",FIPS + "\\AllRoadsParish" + fip + ".shp",query2)
  
  ## Create Address Locator ##
  Output_Address_Locator = "C:\\Users\\D2148\\Documents\\Maps\\FIPS\\add" + fip
     
  arcpy.CreateAddressLocator_geocoding("US Address - Street Name", "AllRoadsParish" + fip + " 'Primary Table'", "'Feature ID' OBJECTID VISIBLE NONE;'Prefix Direction' PREFIX VISIBLE NONE;'Prefix Type' <None> VISIBLE NONE;'*Street Name' NAME VISIBLE NONE;'Suffix Type' Street_Cat VISIBLE NONE;'Suffix Direction' SUFFIX VISIBLE NONE;'Left City or Place' <None> VISIBLE NONE;'Right City or Place' <None> VISIBLE NONE;'Left ZIP Code' ZIPL VISIBLE NONE;'Right ZIP Code' ZIPR VISIBLE NONE;'Left State' STATE VISIBLE NONE;'Right State' STATE VISIBLE NONE;'Left Additional Field' Parish_FIP VISIBLE NONE;'Right Additional Field' Parish_FIP VISIBLE NONE", Output_Address_Locator, "")
    
 

Final Code
0 Kudos