[GRASS-user] v.in.ogr: encoding problem with shapefile DBF file

Hi,

I'm getting an error on attempting to import a shapefile with a DBF file
containing Thai characters (sample below) using v.in.ogr. I've also
attempted to set encoding as per
https://grass.osgeo.org/grass70/manuals/v.in.ogr.html

The file is utf-8 and the headers do not contain Thai characters.

I can open the file in QGIS and view Thai characters in its attribute table,
but in GRASS, only the attribute column headers are imported.

I'd be grateful for any suggestions.

Cheers,
Richard

Error from GRASS command console:
v.in.ogr input= ../Bridge.shp layer=Bridge output=Bridge --overwrite
encoding=utf8
Check if OGR layer <Bridge> contains polygons...
WARNING: Vector map <Bridge> already exists and will be overwritten
Importing 1189 features (OGR layer <Bridge>)...
DBMI-PostgreSQL driver error:
Unable to execute:
insert into public.Bridge values ( 1, '', '', '',
0.00000000000, 0.00000000000, 0.00000000000,
'ถนนประชาร่วมใจ', '6', 6, 0, 0,
0.00000000000, 6.00000000000, '', '', 0, 0, 0, 0, 0, 0, 0,
0, '', 0, 0, '', '', '', '', '', 0.00000000000, '', '', '',
'', '', '', 0.00000000000, 0.00000000000, 0.00000000000, '',
'', '', '', 41, 0.00000000000, '', 0.00000000000, 0.000000 )
ERROR: invalid input syntax for type date: ""
LINE 1: ...มใจ', '6', 6, 0, 0, 0.00000000000,
6.00000000000, '', '', 0,...
^
DBMI-PostgreSQL driver error:
Unable to execute:
insert into public.Bridge values ( 1, '', '', '',
0.00000000000, 0.00000000000, 0.00000000000,
'ถนนประชาร่วมใจ', '6', 6, 0, 0,
0.00000000000, 6.00000000000, '', '', 0, 0, 0, 0, 0, 0, 0,
0, '', 0, 0, '', '', '', '', '', 0.00000000000, '', '', '',
'', '', '', 0.00000000000, 0.00000000000, 0.00000000000, '',
'', '', '', 41, 0.00000000000, '', 0.00000000000, 0.000000 )
ERROR: invalid input syntax for type date: ""
LINE 1: ...มใจ', '6', 6, 0, 0, 0.00000000000,
6.00000000000, '', '', 0,...
^
ERROR: Cannot insert new row: insert into public.Bridge values ( 1, '', '',
'', 0.00000000000, 0.00000000000, 0.00000000000, 'ถนนประชาร่วมใจ', '6', 6,
0, 0, 0.00000000000, 6.00000000000, '', '', 0, 0, 0, 0, 0, 0, 0, 0, '', 0,
0, '', '', '', '', '', 0.00000000000, '', '', '', '', '', '', 0.00000000000,
0.00000000000, 0.00000000000, '', '', '', '', 41, 0.00000000000, '',
0.00000000000, 0.000000 )
(Thu Oct 1 13:30:44 2015) Command finished (0 sec)

System info:
GRASS version: 7.0.1svn
GRASS SVN Revision: 65041
Build Date: 2015-04-10
Build Platform: x86_64-unknown-linux-gnu
GDAL/OGR: 1.11.2
PROJ.4: 4.9.0
GEOS: 3.4.2
SQLite: 3.8.2
Python: 2.7.6
wxPython: 2.8.12.1
Platform: Linux-3.13.0-37-generic-x86_64-with-LinuxMint-17.1-rebecca

Top 8 lines of problem column in DBF file:
NameT,C,250
ถนนประชาร่วมใจ

ทางหลวงชนบท สค. 4011
ถนนวัดกระซ้าขาว
ซอยพระราม 2 (ซอย 4)
ถนนเอนกอุดมผล

--
View this message in context: http://osgeo-org.1560.x6.nabble.com/v-in-ogr-encoding-problem-with-shapefile-DBF-file-tp5227195.html
Sent from the Grass - Users mailing list archive at Nabble.com.

On 01/10/15 08:34, RichardCooper wrote:

Hi,

I'm getting an error on attempting to import a shapefile with a DBF file
containing Thai characters (sample below) using v.in.ogr. I've also
attempted to set encoding as per
https://grass.osgeo.org/grass70/manuals/v.in.ogr.html

The file is utf-8 and the headers do not contain Thai characters.

I can open the file in QGIS and view Thai characters in its attribute table,
but in GRASS, only the attribute column headers are imported.

I'd be grateful for any suggestions.

Cheers,
Richard

Error from GRASS command console:
v.in.ogr input= ../Bridge.shp layer=Bridge output=Bridge --overwrite
encoding=utf8
Check if OGR layer <Bridge> contains polygons...
WARNING: Vector map <Bridge> already exists and will be overwritten
Importing 1189 features (OGR layer <Bridge>)...
DBMI-PostgreSQL driver error:
Unable to execute:
insert into public.Bridge values ( 1, '', '', '',
0.00000000000, 0.00000000000, 0.00000000000,
'ถนนประชาร่วมใจ', '6', 6, 0, 0,
0.00000000000, 6.00000000000, '', '', 0, 0, 0, 0, 0, 0, 0,
0, '', 0, 0, '', '', '', '', '', 0.00000000000, '', '', '',
'', '', '', 0.00000000000, 0.00000000000, 0.00000000000, '',
'', '', '', 41, 0.00000000000, '', 0.00000000000, 0.000000 )
ERROR: invalid input syntax for type date: ""

Not sure this is an encoding issue. There seems to be some empty fields that are supposed to be date fields and PostgreSQL doesn't seem to like that.

I don't have a solution for this right now, though.

Moritz

Thanks for the fast reply.

In the end I deleted the columns specified as 'date' and can now import with
Thai content accessible through the GUI attribute table manager.

Cheers,
Richard

--
View this message in context: http://osgeo-org.1560.x6.nabble.com/v-in-ogr-encoding-problem-with-shapefile-DBF-file-tp5227195p5227252.html
Sent from the Grass - Users mailing list archive at Nabble.com.