[Qgis-user] how to avoid the automatic conversion of a session string in a csv file to a number

Nicola Poles nicola.poles at gmail.com
Wed Jul 29 02:26:59 PDT 2015


Apologies to everyone, it seems I misread the documentation. That flag
actually disables the removal of whitespaces, not zeros. Please disregard
the previous email.


On Wed, Jul 29, 2015 at 11:14 AM, Nicola Poles <nicola.poles at gmail.com>
wrote:

> Ciao Tonino,
>
> if you are comfortable using python, you can circumvent the automatic
> trimming of leading and trailing zeros by adding your CSV layer from
> python. From the API documentation
> http://qgis.org/api/classQgsVectorLayer.html in the "*Delimited text file
> data provider*" Section, you'll see that by setting the *trimFields *flag
> to "no" your leading zero shouldn't be removed anymore.
>
> P.S. If you are interested, I can try to help you with writing a python
> script. Feel free to contact me in private.
>
> *Nicola Poles*
>
> *SOC Settore Tecnico-Scientifico*
>
> *ARPA Friuli Venezia-Giulia*
>
> *Via Cairoli, 14 – 33057 Palmanova (UD)*
>
> *Tel. 0432-191 8073 (8199)*
>
> *e-mail: nicola.poles at arpa.fvg.it <nicola.poles at arpa.fvg.it> *
>
> On Wed, Jul 29, 2015 at 10:18 AM, CONTI Tonino <t.conti at comune.jesi.an.it>
> wrote:
>
>>  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 <t.conti at comune.jesi.an.it>*
>> *www.comune.jesi.an.it/sit <http://www.comune.jesi.an.it/sit>*
>>
>> _______________________________________________
>> Qgis-user mailing list
>> Qgis-user at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/qgis-user
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20150729/6b740c73/attachment.html>


More information about the Qgis-user mailing list