Export Feature Attribute to ASCII (Spatial Statistics)

License Level:BasicStandardAdvanced

Summary

Exports feature class coordinates and attribute values to a space, comma, or semi-colon delimited ASCII text file.

Illustration

Export Feature Attribute to ASCII tool illustration
Coordinates (X and Y) and user-specified feature attributes are written to an ASCII text file.

Usage

Syntax

ExportXYv_stats (Input_Feature_Class, Value_Field, Delimiter, Output_ASCII_File, Add_Field_Names_to_Output)
ParameterExplanationData Type
Input_Feature_Class

The feature class from which to export feature coordinates and attribute values.

Feature Layer
Value_Field
[Value_Field,...]

The field or fields in the input feature class containing the values to export to an ASCII text file.

Field
Delimiter

Specifies how feature coordinates and attribute values will be separated in the output ASCII file.

  • SPACEFeature coordinates and attribute values will be separated by a space in the output.
  • COMMAFeature coordinates and attribute values will be separated by a comma in the output.
  • SEMI-COLONFeature coordinates and attribute values will be separated by a semicolon in the output.
String
Output_ASCII_File

The ASCII text file that will contain the feature coordinate and attribute values.

File
Add_Field_Names_to_Output
  • NO_FIELD_NAMESNo field names will be included in the output text file (default).
  • ADD_FIELD_NAMESField names will be written to the output text file.
Boolean

Code Sample

ExportFeatureAttributeToASCII Example (Python Window)

The following Python Window script demonstrates how to use the ExportFeatureAttributeToASCII tool.

import arcpy
arcpy.env.workspace = r"c:\data"
arcpy.ExportXYv_stats("AidsByCaCnty.shp","HEPRATE", "SPACE","aidsbycacnty.txt","ADD_FIELD_NAMES")
ExportFeatureAttributeToASCII Example (Stand-alone Python script)

The following stand-alone Python script demonstrates how to use the ExportFeatureAttributeToASCII tool.

# Export feature locations and attributes to an ASCII text file
 
# Import system modules
import arcpy
 
# Local variables...
workspace = "c:/data"
input_features = "AidsByCaCnty.shp"
export_ASCII = "aidsbycacnty.txt"
 
try:
    # Set the current workspace (to avoid having to specify the full path to the feature classes each time)
    arcpy.env.workspace = workspace
 
    # Process: Export Feature Attribute to ASCII...
    arcpy.ExportXYv_stats(input_features, "HEPRATE", "SPACE", export_ASCII, "NO_FIELD_NAMES")
 
except:
    # If an error occurred when running the tool, print out the error message.
    print arcpy.GetMessages()

Environments

Related Topics

Licensing Information

ArcGIS for Desktop Basic: Yes
ArcGIS for Desktop Standard: Yes
ArcGIS for Desktop Advanced: Yes
4/18/2013