Select to view content in your preferred language

python script - forloop tiger files

3980
1
10-09-2014 11:13 AM
Naga_RaghuveerModala
New Contributor II

Can anyone help with the following python code. I am reading TIGER Files 1992 with .F5 extensions into the Quick import tool using python

 

# import system modules import arcpy from arcpy import env import os   arcpy.CheckOutExtension("DataInteroperability")   env.workspace = "C:/Users/raghuravi/Desktop/GabeWork/TIGER1992" feature_classes = [] for dirname, dirnames, filenames in os.walk("C:/Users/raghuravi/Desktop/GabeWork/TIGER1992"):     for subdirname in dirnames:         print os.path.join(dirname, subdirname)         env.workspace = os.path.join(dirname, subdirname)         fcList = arcpy.ListFiles()         for fc in fcList:             out_name = arcpy.Describe(fc).baseName + "_polygon"             arcpy.QuickImport_interop("""TIGER,fc,"RUNTIME_MACROS,""LFIELD_AS_STRING,YES,TIGER_EXPOSE_FORMAT_ATTRS,,USE_SEARCH_ENVELOPE,NO,SEARCH_ENVELOPE_MINX,0,SEARCH_ENVELOPE_MINY,0,SEARCH_ENVELOPE_MAXX,0,SEARCH_ENVELOPE_MAXY,0,CLIP_TO_ENVELOPE,NO,_MERGE_SCHEMAS,YES"",META_MACROS,""SourceLFIELD_AS_STRING,YES,SourceTIGER_EXPOSE_FORMAT_ATTRS,,SourceUSE_SEARCH_ENVELOPE,NO,SourceSEARCH_ENVELOPE_MINX,0,SourceSEARCH_ENVELOPE_MINY,0,SourceSEARCH_ENVELOPE_MAXX,0,SourceSEARCH_ENVELOPE_MAXY,0,SourceCLIP_TO_ENVELOPE,NO"",METAFILE,TIGER,COORDSYS,,IDLIST,,__FME_DATASET_IS_SOURCE__,true"""",out_name.gdb")

 

I am getting the following error:

ExecuteError: fc is neither a file or directory, Tiger access failed.

Could not open TIGER/Line dataset

Tool execution failed.

Failed to execute (QuickImport)

0 Kudos
1 Reply
XanderBakker
Esri Esteemed Contributor

Not sure if you are still looking for an answer to this question.

If you manually import single file with Interop, does that work? If so, copy the Python snippet of the tool from the Result window and compare the parameters to what you are using in your script. I see a lot of quotes and part of the parameters are commented out in your code.

# import system modules
import arcpy
from arcpy import env
import os
arcpy.CheckOutExtension("DataInteroperability")
env.workspace = "C:/Users/raghuravi/Desktop/GabeWork/TIGER1992"
feature_classes = []
for dirname, dirnames, filenames in os.walk("C:/Users/raghuravi/Desktop/GabeWork/TIGER1992"):
    for subdirname in dirnames:
        print os.path.join(dirname, subdirname)
        env.workspace = os.path.join(dirname, subdirname)
        fcList = arcpy.ListFiles()
        for fc in fcList:
            out_name = arcpy.Describe(fc).baseName + "_polygon"
            arcpy.QuickImport_interop("""TIGER,fc,"RUNTIME_MACROS,""LFIELD_AS_STRING,YES,TIGER_EXPOSE_FORMAT_ATTRS,,USE_SEARCH_ENVELOPE,NO,SEARCH_ENVELOPE_MINX,0,SEARCH_ENVELOPE_MINY,0,SEARCH_ENVELOPE_MAXX,0,SEARCH_ENVELOPE_MAXY,0,CLIP_TO_ENVELOPE,NO,_MERGE_SCHEMAS,YES"",META_MACROS,""SourceLFIELD_AS_STRING,YES,SourceTIGER_EXPOSE_FORMAT_ATTRS,,SourceUSE_SEARCH_ENVELOPE,NO,SourceSEARCH_ENVELOPE_MINX,0,SourceSEARCH_ENVELOPE_MINY,0,SourceSEARCH_ENVELOPE_MAXX,0,SourceSEARCH_ENVELOPE_MAXY,0,SourceCLIP_TO_ENVELOPE,NO"",METAFILE,TIGER,COORDSYS,,IDLIST,,__FME_DATASET_IS_SOURCE__,true"""",out_name.gdb")
0 Kudos