I’m trying to use db.out.ogr to export an attributes table to a csv format for excel. I am using GRASS 7, but not sure what to put in the “dsn=” syntax.
This is the command I have used and the error that has appeared. Further when the file will be created, where can I find it?
db.out.ogr input=distance1 dsn=/home/dof1985/Grass_projects/Waste/Israel/CD-waste/sqlite/sqlite.db format=CSV table=shortest_distance
WARNING: 4695 line(s) found, but not requested to be exported. Verify ‘type’ parameter.
ERROR 1: It seems a file system object called
‘/home/dof1985/Grass_projects/Waste/Israel/CD-
waste/sqlite/sqlite.db’ already exists.
ERROR: Unable to open OGR data source ‘/home/dof1985/Grass_projects/Waste/Israel/CD-waste/sqlite/sqlite.db’
(Mon Apr 1 18:06:48 2013) Command finished (0 sec)
On Mon, Apr 1, 2013 at 5:08 PM, דור פרידמן <dof1985@gmail.com> wrote:
Hi all,
I'm trying to use db.out.ogr to export an attributes table to a csv format
for excel. I am using GRASS 7, but not sure what to put in the "dsn="
syntax.
The dsn parameter is the path + filename to the *output* file.
This is the command I have used and the error that has appeared. Further
when the file will be created, where can I find it?
I’ve corrected my syntax, but have received a new error (it actually export an empty file: ‘nothing to export’), and the csv file is not being created.
That is my syntax:
GRASS 7.0.svn (Israel):~ > db.out.ogr input=allpairs1 dsn=/home/dof1985/Grass_projects/allpairs.csv format=CSV
WARNING: 20167 line(s) found, but not requested to be exported. Verify
‘type’ parameter.
Exported table </home/dof1985/Grass_projects/allpairs.csv.csv>
I have tried to export a map with two tables connected to it. Running v.db.tables -p, I can see that there names are: allpairs1_1 and allpairs_set10k. I would like to export both to either one or two csv files.
I have also attempted to export one table (allpairs1_1) to a distinct map and exporting it, yet have received the same error and there was no file creation.
On Mon, Apr 1, 2013 at 5:08 PM, דור פרידמן <dof1985@gmail.com> wrote:
Hi all,
I’m trying to use db.out.ogr to export an attributes table to a csv format
for excel. I am using GRASS 7, but not sure what to put in the “dsn=”
syntax.
The dsn parameter is the path + filename to the output file.
This is the command I have used and the error that has appeared. Further
when the file will be created, where can I find it?
On Mon, Apr 1, 2013 at 6:10 PM, דור פרידמן <dof1985@gmail.com> wrote:
Thanks Markus.
I've corrected my syntax, but have received a new error (it actually export
an empty file: 'nothing to export'), and the csv file is not being created.
That is my syntax:
GRASS 7.0.svn (Israel):~ > db.out.ogr input=allpairs1
dsn=/home/dof1985/Grass_projects/allpairs.csv format=CSV
WARNING: 20167 line(s) found, but not requested to be exported. Verify
'type' parameter.
Exported table </home/dof1985/Grass_projects/allpairs.csv.csv>
I have applied a fix in 6.4/6.5/7 SVN to db.out.ogr to also support attribute
export in case of line and area vectors.
I have tried to export a map with two tables connected to it. Running
v.db.tables -p, I can see that there names are: allpairs1_1 and
allpairs_set10k. I would like to export both to either one or two csv files.
In SVN (r55589) I have added support for multilayers. Please try. Hence it
would be now:
# to export table connected to vector map as layer 2:
db.out.ogr input=allpairs1 layer=2
dsn=/home/dof1985/Grass_projects/allpairs.csv format=CSV
I tried again to run db.out.ogr as follows, but it seems that it doesn’t support lines. Should I add something to the command? or update something in GRASS? I’ve also tried in another query to use layer in my syntax, yet it didn’t recognize it as a valid one. I apply the same question to this problem as well.
GRASS 7.0.svn (Israel):~ > db.out.ogr input=allpairs dsn=/home/dof1985/Grass_projects/allpairs format=CSV
WARNING: 11277 line(s) found, but not requested to be exported. Verify
‘type’ parameter.
Exported table </home/dof1985/Grass_projects/allpairs.csv>
I have also tried two other methods:
First, I tried using v.out.ogr to a csv format, but it snapped the roads in my map to several segments creating duplicates, thus total of 216,445 entries in the csv file, which is too many in any scale and hard to filter.
I have also tried Moritz suggestion with v.db.select. It was much convenient with only 1428 entries, though they were formed in one cell separated with |. Can I use that command to define for each column to be in a separated column of the csv?
Further more can you recommend of any function that will allow me to filter the exported attributes to the csv file, instead of using excel to do so?
On Tue, Apr 2, 2013 at 10:58 PM, דור פרידמן <dof1985@gmail.com> wrote:
Hi Markus and Moritz,
I tried again to run db.out.ogr as follows, but it seems that it doesn't
support lines. Should I add something to the command? or update something in
GRASS?
Yes, of course
Since I updated it in SVN, you have to either fetch a precompiled binary (e.g.
an updated winGRASS is available by tomorrow) or update from SVN and
recompile (using "svn update"). I don't remember how you installed GRASS 7
at your end...
I have also tried Moritz suggestion with v.db.select. It was much
convenient with only 1428 entries, though they were formed in one cell
separated with |.
The | is the cell separator by default. So, it is not one "cell", but as many "cells" as there are columns in your attribute table. Just indicate | as the separator to the software you use to treat the data afterwards.
Can I use that command to define for each column to be
in a separated column of the csv?
Use the fs= parameter to define a different column separator than |.