csvt file specification

30 views
Skip to first unread message

antonio valanzano

unread,
Mar 22, 2018, 4:08:00 AM3/22/18
to SpatiaLite Users
Is it possbile to specify the format of  csv fields (with a csvt file) when using LOAD CSV/CST from the GUI ?

I have produced such a file using the specification of this  link http://www.gdal.org/drv_csv.html
but when I import a csv file the fields are automatically converted without taking into account the csvt specification.

Eg the value 076 becomes 76


Antonio Valanzano




a.fu...@lqt.it

unread,
Mar 22, 2018, 4:49:23 AM3/22/18
to spatiali...@googlegroups.com
Hi Antonio,

using a companion file (*.csvt) so to specify the intended data
type for each column being imported from a CSV file is an
additional extra feature specifically introduced by GDAL.
it's not part of the most universal CSV format specifications as
generally intended by the many other sw packages implementing
some kind of CSV parser, and AFAIK only GDAL itself is able to
support *.csvt files.

GDAL supports a very nice and effective SpatiaLite driver, so
if you absolutely need to use a *.csvt companion file you
could easily use GDAL for loading your CSV data into a
SpatiaLite DB-file.

bye Sandro

Jukka Rahkonen

unread,
Mar 22, 2018, 4:58:04 AM3/22/18
to spatiali...@googlegroups.com, antonio valanzano
Hi,

If you need leading zeroes in values it means that you have actually
strings, not numbers. Therefore you should create the CSV file
accordingly by using text separators. Make your CSV file to have "076"
and you should get correctly 076 into your Spatialite db without other
tricks.

-Jukka Rahkonen-
> --
> You received this message because you are subscribed to the Google
> Groups "SpatiaLite Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to spatialite-use...@googlegroups.com.
> To post to this group, send email to
> spatiali...@googlegroups.com.
> Visit this group at https://groups.google.com/group/spatialite-users.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages