GRASS logo

NAME - Imports attribute tables in various formats.


database, import, attribute table

SYNOPSIS --help input=name [gdal_config=string] [gdal_doo=string] [db_table=name] [output=name] [key=string] [encoding=string] [--overwrite] [--help] [--verbose] [--quiet] [--ui]


Allow output files to overwrite existing files
Print usage summary
Verbose module output
Quiet module output
Force launching GUI dialog


input=name [required]
Table file to be imported or DB connection string
GDAL configuration options
Comma-separated list of key=value pairs
GDAL dataset open options
Comma-separated list of key=value pairs
Name of table from given DB to be imported
Name for output table
Name for auto-generated unique key column
Encoding value for attribute data

Table of contents

DESCRIPTION imports attribute tables in various formats as supported by the OGR library on the local system (DBF, CSV, PostgreSQL, SQLite, MySQL, ODBC, etc.). Optionally a unique key (ID) column can be added to the table.


Import CSV file

Limited type recognition can be done for Integer, Real, String, Date, Time and DateTime columns through a descriptive file with same name as the CSV file, but .csvt extension (see details here).
# NOTE: create koeppen_gridcode.csvt first for automated type recognition input=koeppen_gridcode.csv output=koeppen_gridcode table=koeppen_gridcode

Import DBF table

Import of a DBF table with additional unique key column (e.g., needed for input=/path/to/mydata.dbf output=census_raleigh key=myid
db.describe -c census_raleigh

Import of a SQLite table input=/path/to/sqlite.db db_table=census_raleigh output=census_raleigh

Import of a PostgreSQL table

# HINT: if the database contains spatial tables, but you want to import a non-spatial
table, set the environmental variable PG_LIST_ALL_TABLES to YES before importing input="PG:host=localhost dbname=ecad user=neteler" \
          db_table=ecad_verona_tmean output=ecad_verona_tmean table=ecad_verona_tmean
db.describe -c ecad_verona_tmean

Import XLS file

To force reading headers, define environmental variable OGR_XLS_HEADERS='FORCE'. Parameter db_table refers to the list within XLS file.
export OGR_XLS_HEADERS='FORCE' input=address.xls db_table=address_data


GRASS SQL interface


Markus Neteler


Available at: source code (history)

Latest change: Wednesday Feb 28 18:00:11 2024 in commit: 7318ecaef46610952a915c8a57a0d1584affdd65

Main index | Database index | Topics index | Keywords index | Graphical index | Full index

© 2003-2024 GRASS Development Team, GRASS GIS 8.3.3dev Reference Manual