[GRASS-user] convert r.report output to spreadsheet format

Miha Staut mihastaut at yahoo.co.uk
Wed Feb 25 02:28:41 EST 2009


If I understood you correctly you want to convert the below text formatted table in a spreadsheet like format. If this is the case why do not you try the OpenOffice.org calc possibility of fixed delimitation. Save the output of r.report in a file with a .csv suffix. Then open it in ooo calc and set for your delimitation fixed width. Then determine manually the coulumn limits. and with a bit of editing you are done. 

Hope it helps

Miha


--- On Wed, 25/2/09, maning sambale <emmanuel.sambale at gmail.com> wrote:

> From: maning sambale <emmanuel.sambale at gmail.com>
> Subject: Re: [GRASS-user] convert r.report output to spreadsheet format
> To: "grass mailing list" <grass-user at lists.osgeo.org>
> Date: Wednesday, 25 February, 2009, 7:51 AM
> Thanks!
> An example of the r.report output:
> |-----------------------------------------------------------------------------|
> |              Category Information               |        
>  |     cell|   %  |
> | #|description                                   | 
> hectares|    count| cover|
> |-----------------------------------------------------------------------------|
> | 1|Siquijor                                      |   
> 31,313|   385511|  0.05|
> | 
> |----------------------------------------------|----------|---------|------|
> |  |112|Broadleaf - open canopy. . . . . . . . . .|     
> 8265|   101755| 26.39|
> |  |140|Mangrove . . . . . . . . . . . . . . . . .|      
> 173|     2125|  0.55|
> |  |210|Agriculture-annual . . . . . . . . . . . .|     
> 7370|    90737| 23.54|
> |  |310|Scrub. . . . . . . . . . . . . . . . . . .|     
> 1063|    13081|  3.39|
> |  |320|Grassland. . . . . . . . . . . . . . . . .|     
> 7185|    88460| 22.95|
> |  |400|Built-up . . . . . . . . . . . . . . . . .|      
> 103|     1270|  0.33|
> |  |510|Inland water . . . . . . . . . . . . . . .|       
> 44|      539|  0.14|
> |  |  *|no data. . . . . . . . . . . . . . . . . .|     
> 7111|    87544| 22.71|
> 
> I want converted to:
> Province,land_cover_code,description,hectares,cell_count,percent_cover
> 
> I will try the cryptic awk lines.
> 
> 
> On Wed, Feb 25, 2009 at 12:12 AM, Giovanni Pasini
> <jynxtor at gmail.com> wrote:
> > maning sambale ha scritto:
> >>
> >> Hi,
> >>
> >> Looking for tips in "transforming"
> r.report output into a
> >> "spreadsheet" like format.
> >>
> >
> > Hi,
> > I use awk (change NF and the other fields $*):
> >
> > r.report -n map=gri_1000_in,dem2_idw_100_slope_rec
> units=h,p,c | awk 'BEGIN
> > {FS="|";OFS="|"} !/---/ &&
> NF==7 {intest=$2} NF==8 {sub(/[ .]*$/,"",$4);
> > print intest, $4, $6}' > report_slope.txt
> >
> > This from a non awk expert!
> >
> > cheers,
> > giovanni
> > _______________________________________________
> > grass-user mailing list
> > grass-user at lists.osgeo.org
> > http://lists.osgeo.org/mailman/listinfo/grass-user
> >
> 
> 
> 
> -- 
> cheers,
> maning
> ------------------------------------------------------
> "Freedom is still the most radical idea of all"
> -N.Branden
> wiki: http://esambale.wikispaces.com/
> blog: http://epsg4253.wordpress.com/
> ------------------------------------------------------
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-user


      



More information about the grass-user mailing list