Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I've written this script to import a csv file using ArcGIS' flavor of python.. ArcPy.. It seems to run fine up until the XYtoLine tool runs and then it fails..

This is the error message...

Traceback (most recent call last):
File "C:\temp\GIS_projects\Sample_tripData\test.py", line 26, in <module>
arcpy.XYToLine_management(input_table,fc,"TSLONGDD","TSLATDD","TELONGDD","TELATDD","GEODESIC","TRIPSEQNUM")
File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\management.py", line 2913, in XYToLine
raise e
ExecuteError: ERROR 999999: Error executing function.
The table was not found. [tripLines]
Failed to execute (XYToLine).

this is the code I am running...

    # Import system modules
import arcinfo
import arcpy
import sys
if arcpy.CheckProduct("ArcInfo") == "Available":
    print "ArcInfo available, processing script..."
    print "importing modules and set environment...."

    #overwrite pre-existing files
    arcpy.env.overwriteOutput = True

    #delete old feature class
    if  arcpy.Exists("c:\\temp\\gis_projects\\sample_tripdata\\test.gdb\\tripLines"):
        arcpy.Delete_management ("c:\\temp\\gis_projects\\sample_tripdata\\test.gdb\\tripLines")

    #set workspace
    arcpy.env.workspace = "c:\\temp\\gis_projects\\sample_tripdata\\test.gdb"
    fc = "tripLines"

    # Set local variables
    print "setting data input and output variables..."
    input_table = "C:\\temp\\GIS_projects\\Sample_tripData\\A6_TEMP_ATL_TRIP_HAULx.csv"

    #XY To Line
    print "running XY to Line Geoprocessing tool..."
    arcpy.XYToLine_management(input_table,fc,"TSLONGDD","TSLATDD","TELONGDD","TELATDD","GEODESIC","TRIPSEQNUM")

    # Process to delete identical line features...
    # Set the field upon which the identicals are found
    fields = "Shape;TRIPSEQNUM;Shape_Length"

    # Set the XY tolerance within which to identical records to be deleted
    xy_tol = "0.0002 Miles"

    # Set the Z tolerance to default
    z_tol = "0"

    print "Deleteing identical features..."
    # Execute Delete Identical 
    arcpy.DeleteIdentical_management(fc, fields, xy_tol, z_tol)

    print "Dropping leading character..."

    cursor = arcpy.UpdateCursor(fc)
    field = "TRIPSEQNUM"
    row = cursor.next()
    while row:
      # set value of field to only those values after the zero value location
      # I want to strip off the first character within the value of the field
      row.setValue(field, row.getValue(field)[0:])
      cursor.updateRow(row)
      row = cursor.next()

    del fc, input_table, row, cursor, out_lines, input_table, fields, xy_tol, z_tol, field

    print "Processing Complete!"

else:
    print "ArcInfo license not available"
    sys.exit("ArcInfo license not available")

I've been over this a bunch of times and I still keep getting this error.. anyone have any ideas as to what is going on?

thanks in advance

share|improve this question
3  
Have you compared the format of your *.csv to that required by the tool help where it says "If you use text files and .csv (comma-separated value) files as input, make sure that they follow the file structure specified in About_tabular_data_sources"? –  PolyGeo Jun 8 '13 at 0:19
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.