Opened 8 years ago

Last modified 5 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: grass-dev@…
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)

in reply to:  description ; comment:1 by mmetz, 8 years ago

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_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 ?

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.

in reply to:  1 ; comment:2 by mlennert, 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_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 ?

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 ?

in reply to:  2 comment:3 by mmetz, 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_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 ?

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 martinl, 7 years ago

Milestone: 7.2.17.2.2

comment:5 by martinl, 7 years ago

Milestone: 7.2.27.4.0

All enhancement tickets should be assigned to 7.4 milestone.

comment:6 by neteler, 6 years ago

Milestone: 7.4.07.4.1

Ticket retargeted after milestone closed

comment:7 by neteler, 6 years ago

Milestone: 7.4.17.4.2

comment:8 by martinl, 6 years ago

Milestone: 7.4.27.6.0

All enhancement tickets should be assigned to 7.6 milestone.

comment:9 by martinl, 5 years ago

Milestone: 7.6.07.6.1

Ticket retargeted after milestone closed

comment:10 by martinl, 5 years ago

Milestone: 7.6.17.6.2

Ticket retargeted after milestone closed

Note: See TracTickets for help on using tickets.