[GRASSLIST:4648] Re: creating a table from ascii data?
Glynn Clements
glynn at gclements.plus.com
Tue Oct 26 20:36:57 EDT 2004
Hamish wrote:
> > > I am trying to convert a multi column text file[*] into a table
> > > which I can then connect to a (5.7) vector map. I can't quite see
> > > how to do this. Any ideas?
> > > This is for a script, so "use OpenOffice & save as DBF" won't work.
> > >
> > > [*] say .csv file; col1=cat col2=attr, etc.
> >
> > How about the PostgreSQL copy command?
^^^^^^^^^^
> [yes, that is the command I was looking for]
>
>
> I'm still having problems:
>
> NAME=vector_map
> ATTR_FILE="${TMP}.route_atts" # includes absolute path
> ATTR_COLS='cat int, route_id int, name varchar(20), start_wpt varchar(10)'
>
> # check that 'db.connect -p' exists
>
> # create attr database
> echo "CREATE TABLE $NAME ($ATTR_COLS)" | db.execute
>
> # next populate it
> echo "COPY $NAME FROM '$ATTR_FILE'" | db.execute
>
> # finally connect it to existing vector map
> v.db.connect map="$NAME" table="$NAME"
>
>
>
> The COPY step gives an error though:
> ($GISDBASE/$LOCATION/$MAPSET/.tmp/$HOSTNAME/ shortened to /tmp here)
>
> [...]
> v.in.ascii: line vector "test_rte" successfully created
> D2/5: add_table(): table = test_rte name = test_rte.dbf
> D3/5: sql: COPY test_rte FROM '/tmp/23569.0.route_atts'
>
> DBMI-DBF driver error:
^^^
The DBF driver doesn't support the COPY command.
The PostgreSQL documentation for the COPY command says:
Compatibility
There is no COPY statement in the SQL standard.
I.e. it's a PostgreSQL extension.
--
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-user
mailing list