[GRASS-user] Inconsistent number of column in the table
Daniel Victoria
daniel.victoria at gmail.com
Wed Jul 4 04:28:24 PDT 2018
Hi Micha,
It worked! I only had to make a minor change to process all inside grass.
So for future reference, what I did was:
db.execute sql='update solos set horizonte = replace(horizonte, char(10), "
")'
I could not use the line break in the db.execute sql statement. But I found
that char(10) is the same thing [1].
Cheers
Daniel
[1] -
https://stackoverflow.com/questions/23930865/new-line-character-n-in-sqlite-concatenate
On Tue, Jul 3, 2018 at 5:53 PM Micha Silver <tsvibar at gmail.com> wrote:
>
>
> On 07/03/2018 10:39 PM, Daniel Victoria wrote:
>
> Hi list,
>
> Sorry to resurface an old problem. At the time I was able to 'circle
> around' this 'inconsistent number of column' issue. But now it came back
> (like all good problems do).
>
> Anyway, I imported a large soil map with v.in.ogr, whitout errors. But
> when I try to open the attribute table (Show attribute table in GUI
> dialog), I get an error saying "Inconsistent number of column in the
> table". The Attribute table manager then opens but I can't browse the data.
>
> v.db.select on the CLI works fine so I suspect it's a problem with special
> characters in the attribute table messing up with the attribute table GUI.
>
> The data has lots of special characters (accents) and they show up fine in
> v.db.select. But I suspect the main problem is that the attribute table has
> line breaks! Yes, someone has placed line brakes in the attribute table.
> Yikes...
>
> Any idea how to clean this attribute table? The only thing I could think
> of is opening the shapefile in R or Python and try to substitute the "\n"
> character.
>
> I think you can do this straight in sqlite (assuming your backend db for
> this vector is sqlite) using the builtin sql function replace().
> Here's an example:
>
> sqlite> create table t1 (id integer primary key, label text);
> sqlite> insert into t1 (label) values ('ab
> ...> cd');
> sqlite> insert into t1 (label) values ('xyz
> ...> abc');
> sqlite>
> sqlite> select * from t1;
> 1|ab
> cd
> 2|xyz
> abc
>
> Now the replace trick:
>
> sqlite> update t1 set label=replace(label, '
> ...> ', '');
> sqlite> select * from t1;
> 1|ab cd
> 2|xyz abc
> sqlite>
>
> HTH
>
>
> Cheers
> Daniel
>
> On Tue, Jan 16, 2018 at 10:13 PM Daniel Victoria <
> daniel.victoria at gmail.com> wrote:
>
>> That is probably the case.
>> Is there a way to 'sanitize' this shapefile DBF prior to v.in.ogr?
>>
>> Or the fact that v.db.select works on the CLI means that the attribute
>> table is OK. It's more a visualization problem with the GUI attribute table
>> manager.
>>
>> Thanks
>> Daniel
>>
>>
>> On Tue, Jan 16, 2018 at 6:15 PM Helmut Kudrnovsky <hellik at web.de> wrote:
>>
>>> DanielV wrote
>>> > Hi List,
>>> >
>>> > I imported a large vector shapefile into grass. v.in.ogr did not report
>>> > any
>>> > errors. However, when I try to open the attribute table (Show attribute
>>> > table in GUI dialog), I get an error saying "Inconsistent number of
>>> column
>>> > in the table". The Attribute table manager then opens but I can't
>>> browse
>>> > the data. However, table is correctly described (column names and data
>>> > type).
>>> >
>>> > From the CLI, v.db.select will print the contents of the attribute
>>> table
>>> > without any complains.
>>> >
>>> > Any idea how to troubleshoot this?
>>>
>>> are there any special characters in the table content, e.g. ' or " or ;
>>> or ,
>>> or / or \ .... etc?
>>>
>>>
>>>
>>> -----
>>> best regards
>>> Helmut
>>> --
>>> Sent from: http://osgeo-org.1560.x6.nabble.com/Grass-Users-f3884509.html
>>> _______________________________________________
>>> grass-user mailing list
>>> grass-user at lists.osgeo.org
>>> https://lists.osgeo.org/mailman/listinfo/grass-user
>>
>>
>
> _______________________________________________
> grass-user mailing listgrass-user at lists.osgeo.orghttps://lists.osgeo.org/mailman/listinfo/grass-user
>
>
> --
> Micha Silver
> Ben Gurion Univ.
> Sde Boker, Remote Sensing Lab
> cell: +972-523-665918
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20180704/df6c3f51/attachment-0001.html>
More information about the grass-user
mailing list