#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
Resolution:               |   Keywords:  v.in.ogr column names SQL
       CPU:  Unspecified  |   Platform:  Unspecified
--------------------------+---------------------------------------

Comment (by mmetz):

 Replying to [ticket:3164 mlennert]:
 > 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 ?

 A different G_str_to_sql() function would be needed, currently it is
 {{{
 int G_str_to_sql(char *str)
 }}}
 but you would need
 {{{
 int G_str_to_sql2(char **str)
 }}}
 because the buffer needs to be enlarged by 1 (realloc'd) which means the
 address pointed to by str will change. Then shift the characters by 1
 towards the end and insert x at the beginning.

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

_______________________________________________
grass-dev mailing list
grass-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-dev

Reply via email to