[GIS] Converting text file with coordinates to database table in ArcGIS Desktop with Python

arcgis-desktoparcpyconvertdbfpython

How do I convert a text file with point coordinates to database tables in the dBase (*.dbf) format in Python?

I am using ArcGIS Desktop.

Best Answer

You can use Table to Table (Conversion) or Copy Rows (Data Management) here. Both of them have a very similar structure.

Usage of Table to Table:

This tool supports the following table formats as input:
    dBASE (.dbf)
    Comma Separate Value (.csv)
    tab delimited text (.txt)
    Microsoft Excel worksheets (.xls or .xlsx)
    INFO
    VPF
    OLE database
    personal, file, or SDE geodatabase
    in-memory table views

For file input (.csv or .txt), the first row of the input file is used as the field
names on the output table. Field names cannot contain spaces or special characters 
(such as $ or *), and you will receive an error if the first row of input file 
contains spaces or special characters.

Syntax

TableToTable_conversion (in_rows, out_path, out_name, {where_clause}, {field_mapping}, {config_keyword})

Example:

import arcpy
from arcpy import env
env.workspace = "C:/data"
arcpy.TableToTable_conversion("inputFile.txt", "C:/output/Dbase.dbf", "outputFile")
Related Question