Opened 6 years ago
Last modified 5 years ago
#3747 new enhancement
Allow appending instead of overwriting an output file in relevant statistics or attribute reporting modules
Reported by: | Nikos Alexandris | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | 7.8.3 |
Component: | Default | Version: | unspecified |
Keywords: | Cc: | ||
CPU: | Unspecified | Platform: | Unspecified |
Description
We frequently report statistics for multiple maps. It would be very useful to allow appending to an existing file, instead of overwriting it, by adding a flag/parameter to relevant modules such as https://grass.osgeo.org/grass76/manuals/r.stats.html or even https://grass.osgeo.org/grass76/manuals/r.univar.html.
(The latter, though, computes the overall statistics if many maps are given as an input. Perhaps a flag could allow for a serial output of statistics for each input raster map separately.)
Here a suggested example (verified that works) for r.stats
, in the context of this thread https://lists.osgeo.org/pipermail/grass-dev/2018-August/089377.html:
Index: raster/r.stats/main.c =================================================================== --- raster/r.stats/main.c (révision 72717) +++ raster/r.stats/main.c (copie de travail) @@ -223,7 +223,7 @@ name = option.output->answer; if (name != NULL && strcmp(name, "-") != 0) { - if (NULL == freopen(name, "w", stdout)) { + if (NULL == freopen(name, "a", stdout)) { G_fatal_error(_("Unable to open file <%s> for writing"), name); } }