[GRASS-dev] [GRASS GIS] #3164: v.in.ogr: "Column name <1_AVERAGE> renamed to <x_AVERAGE>" should be x1_AVERAGE or similar

GRASS GIS trac at osgeo.org
Mon Sep 19 09:13:11 PDT 2016


#3164: v.in.ogr: "Column name <1_AVERAGE> renamed to <x_AVERAGE>" should be
x1_AVERAGE or similar
---------------------------------------+-------------------------
 Reporter:  mlennert                   |      Owner:  grass-dev@…
     Type:  enhancement                |     Status:  new
 Priority:  normal                     |  Milestone:  7.2.1
Component:  Vector                     |    Version:  unspecified
 Keywords:  v.in.ogr column names SQL  |        CPU:  Unspecified
 Platform:  Unspecified                |
---------------------------------------+-------------------------
 Trying to import a vector file which has columns such as 1_AVERAGE,
 2_AVERAGE, etc, I get the following error message:


 {{{
 Column name <1_AVERAGE> renamed to <x_AVERAGE>
 Column name <2_AVERAGE> renamed to <x_AVERAGE>
 Column name <3_AVERAGE> renamed to <x_AVERAGE>
 Column name <4_AVERAGE> renamed to <x_AVERAGE>
 Column name <5_AVERAGE> renamed to <x_AVERAGE>
 Column name <6_AVERAGE> renamed to <x_AVERAGE>
 Column name <1_STDDEV> renamed to <x_STDDEV>
 Column name <2_STDDEV> renamed to <x_STDDEV>
 Column name <3_STDDEV> renamed to <x_STDDEV>
 Column name <4_STDDEV> renamed to <x_STDDEV>
 Column name <5_STDDEV> renamed to <x_STDDEV>
 Column name <6_STDDEV> renamed to <x_STDDEV>
 DBMI-SQLite erreur de pilote :
 Error in sqlite3_prepare():
 duplicate column name: x_AVERAGE
 DBMI-SQLite erreur de pilote :
 Error in sqlite3_prepare():
 duplicate column name: x_AVERAGE
 }}}

 This comes from G_str_to_sql() in
 [https://trac.osgeo.org/grass/browser/grass/trunk/lib/gis/strings.c#L356
 lib/gis/strings.c] which just checks whether the first character is a
 letter and, if not, replaces it with 'x':


 {{{
     c = str;
     if (!(*c >= 'A' && *c <= 'Z') && !(*c >= 'a' && *c <= 'z')) {
         *c = 'x';
         count++;
     }
 }}}

 I know the reasoning behind this procedure, and I know I can use the
 'columns' parameter to provide my own names, but in a file like this one
 where you have 12 such columns, this is work which I believe we shouldn't
 oblige the user to go through.

 Why not just add x in front of the string (i.e. 1_AVERAGE becomes
 x1_AVERAGE instead of x_AVERAGE) ?

 Any objections to that ? And as my pointer foo is a bit low, could someone
 give me a hint on how to do that ? I guess it would entail ensuring that c
 has enough memory space to add a character ?

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/3164>
GRASS GIS <https://grass.osgeo.org>



More information about the grass-dev mailing list