Hi Martin,<br><br>Thank you very much, this is exactly what i needed...<br>However, you were right...the truncation seems to be a limitation of the OGR driver/Mapinfo Format.<br><br>Thanks again,<br><br clear="all">Romain,<div>
<i><br></i></div><br>
<br><br><div class="gmail_quote">2011/7/19 Martin Dobias <span dir="ltr"><<a href="http://wonder.sk">wonder.sk</a>@<a href="http://gmail.com">gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi Romain<br>
<br>
On Sun, Jul 17, 2011 at 11:23 PM, romain <<a href="mailto:romain.riviere.974@gmail.com">romain.riviere.974@gmail.com</a>> wrote:<br>
> Sorry, I think i haven't explained well what I want.<br>
><br>
> I know how to get my fields' lengths from SpatiaLite.<br>
><br>
> Here is what I've already done:<br>
> 1/ create QgsvectorLayer from spatiaLite table : vlayer<br>
> 2/ strore field's length in a python list: lengths<br>
><br>
> One of my text fields (FIELD1) have 300 characters....<br>
><br>
><br>
> What my problem is when i want to save the layer as mapinfo file with :<br>
><br>
> QgsVectorFileWritter.writteAsFromat(vlayer,........,mapinfo)<br>
><br>
> -> The mapinfo File is created but all the fields are truncated at 254<br>
> char.... So, I lost informations on FIELD1...<br>
<br>
There is one more way how to use QgsVectorFileWriter:<br>
1. construct QgsVectorFileWriter object<br>
2. call addFeature() for each feature you want add<br>
3. delete the writer object (in order to save changes)<br>
<br>
This is essentially what writeAsFormat() function does. But using the<br>
above approach has more flexibility: in the constructor you pass a map<br>
of fields - so instead of using input layer's field definitions you<br>
could change them and set higher (or lower) length, rename some fields<br>
etc.<br>
<br>
<br>
> I've tried to set fields lengths for my layer, in order to avoid truncature,<br>
> but, it doesn't change anything:<br>
><br>
> fields=vlayer.dataProvider().fields()<br>
> for field in fields:<br>
> fields[field].setLength(301)<br>
<br>
This will not work because you are changing the length only of the<br>
local object: this change will not get back to the provider.<br>
<br>
<br>
> The only thing I need is to pass an option to Qgsvectorfilewritter to change<br>
> fields maximum characters...<br>
> Does anybody know how to do this directly with OGR ? (within python, of<br>
> course)<br>
<br>
Another problem could be that the truncation is a limitation of the<br>
format or OGR driver...<br>
<br>
Regards<br>
<font color="#888888">Martin<br>
</font></blockquote></div><br>