[Qgis-user] how to avoid the automatic conversion of a session string in a csv file to a number
Chris Crook
ccrook at linz.govt.nz
Wed Jul 29 11:03:46 PDT 2015
Hi Tonino
You can force the data type of columns using a .csvt file that that you install alongside the .csv file. This file is a text file with one line defining the types of each field. You can read about this in the help for the delimited text provider (though it is quite brief). I've copied the relevant section below:
QGIS can also read the types from an OGR CSV driver compatible "csvt" file. This is a file alongside the data file, but with a "t" appended to the file name. The file should just contain one line which lists the type of each field. Valid types are "integer", "real", "string", "date", "time", and "datetime". The date, time, and datetime types are treated as strings in QGIS. Each type may be followed by a width and precision, for example "real(10.4)". The list of types are separated by commas, regardless of the delimiter used in the data file. An example of a valid format file would be:
"integer","string","string(20)","real(20.4)"
You should be able to use this - let me know if you have any difficulty.
Also there is an open feature request for adding the ability to choose types from the dialog box http://hub.qgis.org/issues/13038. This is assigned to me, though I doubt I'll have time to do much with it in the near future.
Cheers
Chris
________________________________________
From: CONTI Tonino [t.conti at comune.jesi.an.it]
Sent: 29 July 2015 20:18
To: qgis-user at lists.osgeo.org
Subject: [Qgis-user] how to avoid the automatic conversion of a session string in a csv file to a number
Dear all,
Can anyone tell me how to prevent qgis automatically convert a csv file from text field to numeric format (double).
I have a csv file where a field contains texts starting with zero (example: "0420050000000009", with the quotes).
When I add to my project file as "layer delimited text," I see the data properly in the preview but when the layer is added in this field is not imported the leading zero recognizing the format as numeric.
I need that the string "0420050000000009" remains unchanged as it represents a unique identifier.
can you help me?
Thank You
Tonino
Dott.Tonino Conti
Comune di Jesi
Sistema Informativo Territoriale
Tel 0731538312 - fax 0731538513
t.conti at comune.jesi.an.it<mailto:t.conti at comune.jesi.an.it>
www.comune.jesi.an.it/sit<http://www.comune.jesi.an.it/sit>
This message contains information, which may be in confidence and may be subject to legal privilege. If you are not the intended recipient, you must not peruse, use, disseminate, distribute or copy this message. If you have received this message in error, please notify us immediately (Phone 0800 665 463 or info at linz.govt.nz) and destroy the original message. LINZ accepts no responsibility for changes to this email, or for any attachments, after its transmission from LINZ. Thank You.
More information about the Qgis-user
mailing list