Re: [GRASS-user] Importing .csv table into GRASS

2009-06-30 Thread JanaKr

Hi everybody, thanks for suggestions; In between I've posted some comments
and wondered why there was no answer to them - now I realized that I've
simply replied to the people sending the comments, not the grass-user forum.
Sorry for the confusion. Here, once more, I attach what I wanted to write to
the grass user forum:

2-nd mail (reply to Moritz):
Actually, the .csv table was made from .dbf table of an existing vector map.
The problem is that I want to use v.db.join to transfer one attribute from
that table to another vector map through a common key; When I tried
v.db.join directly on the .dbf table, it said the .dbf format is not
supported. I am affraid  v.in.ascii will produce a .dbf table, so it does
not serve my purpose.

3-rd mail (reply to Hamish):
Thanks for suggestions. In between I took a way of least resistance  and
achieved my goal by a couple of OpenOffice Calc  operations directly on .dbf
files (instead of using db.in.ogr + v.db.join). However, the method of using
this sequence of commands (db.in.ogr + v.db.join) is recommended and used in
an example in Neteler, Mitasova, 2008: Open Source GIS and GRASS GIS
Approach (Third Edition) - page 180. Therefore, I would like to find out
what's the problem - is there a bug in the GRASS modules, or my .csv file in
not OK?

Thanks for your patience,

Jana



-- 
View this message in context: 
http://n2.nabble.com/Importing-.csv-table-into-GRASS-tp3160360p3180651.html
Sent from the Grass - Users mailing list archive at Nabble.com.

___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


Re: [GRASS-user] Importing .csv table into GRASS

2009-06-30 Thread Moritz Lennert

JanaKr wrote:
I am trying to import a simple okresy.csv table, the first few lines 
of which are:


CAT,AREA,PERIMETER,CISLO_OKR,SO2_KG,SO2_OBYV 
64,9485480,15278.33,101,3384,0.08 66,92488080,53576.26,102,3384,0.03

 62,74758064,39651.84,103,3384,0.05 63,96450584,56394.8,104,3384,0.04


Using  db.in.ogr okresy.csv out=okresy returns error message: Input 
table okresy.csv   not found or not readable



Actually, your problem comes from the fact that your first column is
named CAT. If you look at the db.in.ogr script, it does:

WARNING=`v.in.ogr --q dsn=\$GIS_OPT_DSN\ $LAYER out=$GIS_OPT_OUTPUT
-o --o 21 | grep -i 'ERROR\|cat' | grep -v 'truncated'`
if [ ! -z $WARNING ] ; then
   echo $WARNING
   if [ ! -z $GIS_OPT_DB_TABLE ] ; then
  g.message -e Input DSN $INPUT not found or not readable
   else
  g.message -e Input table $INPUT not found or not readable
   fi
   exit 1
fi


And if you try that with your file:

v.in.ogr --q dsn=test.csv out=test -o --o

GRASS 6.3.0 (gisdemo_ncspm):~  v.in.ogr --q dsn=test.csv out=test -o --o
WARNING: Width for column CAT set to 255 (was not specified by OGR), some
 strings may be truncated!
WARNING: Width for column AREA set to 255 (was not specified by OGR), some
 strings may be truncated!
WARNING: Width for column PERIMETER set to 255 (was not specified by OGR),
 some strings may be truncated!
WARNING: Width for column CISLO_OKR set to 255 (was not specified by OGR),
 some strings may be truncated!
WARNING: Width for column SO2_KG set to 255 (was not specified by OGR),
 some strings may be truncated!
WARNING: Width for column SO2_OBYV set to 255 (was not specified by OGR),
 some strings may be truncated!
DBMI-SQLite driver error:
Error in sqlite3_prepare():
duplicate column name: CAT

ERROR: Cannot create table: create table test (cat integer, CAT varchar (
   255 ), AREA varchar ( 255 ), PERIMETER varchar ( 255 ), CISLO_OKR
   varchar ( 255 ), SO2_KG varchar ( 255 ), SO2_OBYV varchar ( 255 ))


If you rename that first column to ID or something else, it works like a
charm.

In more recent versions, there is an explicit error message which leads
you directly to the problem, although I consider this a bug of the
script, so you might want to file a bug report if it isn't already done.



2-nd mail (reply to Moritz): Actually, the .csv table was made from 
.dbf table of an existing vector map. The problem is that I want to

use v.db.join to transfer one attribute from that table to another
vector map through a common key; When I tried v.db.join directly on
the .dbf table, it said the .dbf format is not supported. I am
affraid  v.in.ascii will produce a .dbf table, so it does not serve
my purpose.


As Hamish mentioned, v.in.ascii only makes sense if your csv file
contains geometries, and not only attribute data. Sorry for misleading you.

Concerning the issue of dbf, GRASS will create the table in the default 
database backend that you define with db.connect, so just define sqlite 
as your default database backend, and it will create a table in an 
sqlite db which you can then use for v.db.join.


Moritz
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


Re: [GRASS-user] Importing .csv table into GRASS

2009-06-29 Thread Markus Neteler
Hi,

you could try the updated version from 6.4:
http://trac.osgeo.org/grass/browser/grass/branches/releasebranch_6_4/scripts/db.in.ogr/db.in.ogr?format=raw

(not sure if it is compliant to 6.3 but worth a try).

Markus

On Fri, Jun 26, 2009 at 10:34 AM, JanaKrjkr...@gmail.com wrote:

 Hello,

 I am trying to import a simple okresy.csv table, the first few lines of
 which are:

 CAT,AREA,PERIMETER,CISLO_OKR,SO2_KG,SO2_OBYV
 64,9485480,15278.33,101,3384,0.08
 66,92488080,53576.26,102,3384,0.03
 62,74758064,39651.84,103,3384,0.05
 63,96450584,56394.8,104,3384,0.04

 Using  db.in.ogr okresy.csv out=okresy returns error message:
 Input table okresy.csv   not found or not readable

 I am using Linux installation of GRASS 6.3, I tried to use full path to the
 .csv file, I tried to move it to current directory, but the message was
 always the same. Then I thought maybe my .csv file is not OK ... so I
 checked the http://www.gdal.org/ogr/drv_csv.html, but seems OK.

 Does anyone have any clue?



 --
 View this message in context: 
 http://n2.nabble.com/Importing-.csv-table-into-GRASS-tp3160360p3160360.html
 Sent from the Grass - Users mailing list archive at Nabble.com.

 ___
 grass-user mailing list
 grass-user@lists.osgeo.org
 http://lists.osgeo.org/mailman/listinfo/grass-user

___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


Re: [GRASS-user] Importing .csv table into GRASS

2009-06-26 Thread Moritz Lennert

On 26/06/09 10:34, JanaKr wrote:

Hello,

I am trying to import a simple okresy.csv table, the first few lines of
which are:  


CAT,AREA,PERIMETER,CISLO_OKR,SO2_KG,SO2_OBYV
64,9485480,15278.33,101,3384,0.08
66,92488080,53576.26,102,3384,0.03
62,74758064,39651.84,103,3384,0.05
63,96450584,56394.8,104,3384,0.04

Using  db.in.ogr okresy.csv out=okresy returns error message:
Input table okresy.csv   not found or not readable

I am using Linux installation of GRASS 6.3, I tried to use full path to the
.csv file, I tried to move it to current directory, but the message was
always the same. Then I thought maybe my .csv file is not OK ... so I
checked the http://www.gdal.org/ogr/drv_csv.html, but seems OK.

Does anyone have any clue?


use v.in.ascii ?

Moritz
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user