Opened 8 years ago
Last modified 6 years ago
#3164 new enhancement
v.in.ogr: "Column name <1_AVERAGE> renamed to <x_AVERAGE>" should be x1_AVERAGE or similar
Reported by: | mlennert | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | 7.6.2 |
Component: | Vector | Version: | unspecified |
Keywords: | v.in.ogr column names SQL | Cc: | |
CPU: | Unspecified | Platform: | Unspecified |
Description
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 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 ?
Change History (10)
follow-up: 2 comment:1 by , 8 years ago
follow-up: 3 comment:2 by , 8 years ago
Replying to mmetz:
Replying to 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_AVERAGEThis comes from G_str_to_sql() in 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.
Finally, coming back to this after foss4g.be.
Just to prove my ignorance: wouldn't G_rasprintf be appropriate for this ?
comment:3 by , 8 years ago
Replying to mlennert:
Replying to mmetz:
Replying to 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_AVERAGEThis comes from G_str_to_sql() in 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.
Finally, coming back to this after foss4g.be.
Just to prove my ignorance: wouldn't G_rasprintf be appropriate for this ?
Of course G_rasprintf would be appropriate, but you still need to pass char **
and not char *
to a new version of G_str_to_sql.
comment:4 by , 8 years ago
Milestone: | 7.2.1 → 7.2.2 |
---|
comment:5 by , 7 years ago
Milestone: | 7.2.2 → 7.4.0 |
---|
All enhancement tickets should be assigned to 7.4 milestone.
comment:7 by , 6 years ago
Milestone: | 7.4.1 → 7.4.2 |
---|
comment:8 by , 6 years ago
Milestone: | 7.4.2 → 7.6.0 |
---|
All enhancement tickets should be assigned to 7.6 milestone.
Replying to mlennert:
A different G_str_to_sql() function would be needed, currently it is
but you would need
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.