5

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.

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked May 17, 2012 at 9:53

2 Answers 2

5

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")
PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
answered May 17, 2012 at 10:10
4

As you're using ArcGIS, Aragon's answer should be sufficient. However, you can do it without ArcPy too. Python has a module for reading CSVs. You can then use dbfpy to write out the DBF. I believe there is a PyPi module for reading and writing to XLS, which might also serve.

answered May 18, 2012 at 13:05

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.