<div dir="ltr">We're also specifying the GEOM_POSSIBLE_NAMES, so it would be great if with that option we could use the GEOMETRY_NAME without using the CREATE_CSVT=YES option.<div><br></div><div>Regarding emitting the .prj and .csvt in /vsistdout mode, that's why I'm saying that there is an issue while generating the resultant CSV.</div><div>The way we see it is that when using the /vsistdout mode, the result is a CSV file with the .prj information in the first line, and the .csvt in the second line. We're dealing with the result deleting the first two lines and using the rest of the content as a CSV, which should be equal to the result obtained when using ogr2ogr without the CREATE_CSVT=YES option.</div><div>Probably we're losing something, but as we see it, the generated CSV should be a valid one. Does that make sense?</div><div><br></div><div>Thanks so much for your help!</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">El mié, 3 may 2023 a las 15:10, Robert Hewlett (<<a href="mailto:rob.hewy@gmail.com">rob.hewy@gmail.com</a>>) escribió:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto">The .CSVT and .PRJ help to make a proper geocsv dataset. Helps with QGIS And geopandas. The column name that I use in the CSV is usually geom and WKT shows up in the CSVT file which seems to be a one line file that hints at the data types in the CSV file.<div dir="auto"><div dir="auto"><br></div><div dir="auto">I hope that makes sense.</div><div dir="auto"><br></div><div dir="auto">CSVT</div><div dir="auto">Integer, Integer,WKT</div><div dir="auto"><br></div><div dir="auto">CSV</div><div dir="auto">line_id,point_id,geom</div><div dir="auto">1,1,"POINT(1000 1000)"</div><div dir="auto"><br></div><div dir="auto">PRJ</div><div dir="auto">EPSG:26910</div><div dir="auto"><br></div><div dir="auto"><br></div><div dir="auto"><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, May 3, 2023, 05:23 Moises Calzado via gdal-dev <<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi Even,<div><br></div><div>Thanks so much for taking a look into that one!</div><div><br></div><div>I have one doubt regarding the CSVT content, as we're not really using it, but it's required when using the GEOMETRY_NAME layer creation option, as can be checked in the CSV driver documentation:</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><ul style="box-sizing:border-box;margin:0px 0px 24px;padding:0px;list-style-position:initial;line-height:24px;color:rgb(64,64,64);font-family:Lato,proxima-nova,"Helvetica Neue",Arial,sans-serif;font-size:16px;background-color:rgb(252,252,252)"><li style="margin-left:24px;box-sizing:border-box;list-style:disc"><p style="box-sizing:border-box;line-height:24px;margin:0px"><span style="box-sizing:border-box;font-weight:700">GEOMETRY_NAME</span>=name (Starting with GDAL 2.1): Name of geometry column. Only used if GEOMETRY=AS_WKT and CREATE_CSVT=YES. Defaults to WKT</p></li></ul></blockquote><div>We really need this flag as we are processing files that contain geometries with different column names, and we always want the same geometry name in the generated output. Are we losing something when using that flag to avoid this problem?</div><div>In my humble opinion, generating an invalid CSV when using the -lco CREATE_CSVT=YES looks like a bug for me, as I can't see the reason why strings containing line breaks can't be quoted.</div><div><br></div><div>Could you please shed some light on this?</div><div><br></div><div>Looking forward to your reply,</div><div>Regards.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">El mié, 3 may 2023 a las 14:00, Even Rouault (<<a href="mailto:even.rouault@spatialys.com" rel="noreferrer" target="_blank">even.rouault@spatialys.com</a>>) escribió:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
<p>you didn't post to the list<br>
</p>
<div>Le 03/05/2023 à 13:49, Moises Calzado a
écrit :<br>
</div>
<blockquote type="cite">
<div dir="ltr">Hi Even,
<div><br>
</div>
<div>Thanks so much for taking a look into that one!</div>
<div><br>
</div>
<div>I have one doubt regarding the CSVT content, as we're not
really using it, but it's required when using the
GEOMETRY_NAME layer creation option, as can be checked in the
CSV driver documentation:</div>
<div><br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<ul>
<li style="box-sizing:border-box;list-style:disc;margin-left:24px">
<p style="box-sizing:border-box;line-height:24px;margin:0px"><span style="box-sizing:border-box;font-weight:700">GEOMETRY_NAME</span>=name
(Starting with GDAL 2.1): Name of geometry column. Only
used if GEOMETRY=AS_WKT and CREATE_CSVT=YES. Defaults to
WKT</p>
</li>
</ul>
</blockquote>
<div>We really need this flag as we are processing files
that contain geometries with different column names, and we
always want the same geometry name in the generated output.
Are we losing something when using that flag to avoid this
problem?</div>
<div>In my humble opinion, generating an invalid CSV when using
the -lco CREATE_CSVT=YES looks like a bug for me, as I can't
see the reason why strings containing line breaks can't be
quoted.</div>
<div><br>
</div>
<div>Could you please shed some light on this?</div>
<div><br>
</div>
<div>Looking forward to your reply,</div>
<div>Regards.</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">El sáb, 29 abr 2023 a las
15:44, Even Rouault (<<a href="mailto:even.rouault@spatialys.com" rel="noreferrer" target="_blank">even.rouault@spatialys.com</a>>)
escribió:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
<p>Moises,</p>
<p>as far as I can see with your example, the CSV driver
behaves "properly" in reading and writing of field values
with line breaks.</p>
<p>It follows the "Fields with embedded line breaks must be
quoted" rule of <a href="https://en.wikipedia.org/wiki/Comma-separated_values" rel="noreferrer" target="_blank">https://en.wikipedia.org/wiki/Comma-separated_values</a><br>
</p>
<p>$ ogr2ogr out.csv /vsizip/dataframe.zip<br>
</p>
<p>$ cat out.csv<br>
id,descriptio<br>
"1",This is my third row<br>
"2","this is<br>
my string<br>
"<br>
"3",This is my third row<br>
</p>
<p>$ ogrinfo out.csv -al<br>
INFO: Open of `out.csv'<br>
using driver `CSV' successful.<br>
<br>
Layer name: out<br>
Geometry: None<br>
Feature Count: 3<br>
Layer SRS WKT:<br>
(unknown)<br>
id: String (0.0)<br>
descriptio: String (0.0)<br>
OGRFeature(out):1<br>
id (String) = 1<br>
descriptio (String) = This is my third row<br>
<br>
OGRFeature(out):2<br>
id (String) = 2<br>
descriptio (String) = this is<br>
my string<br>
<br>
<br>
OGRFeature(out):3<br>
id (String) = 3<br>
descriptio (String) = This is my third row<br>
<br>
</p>
<p>But in your example using /vsistdout/ and -lco
CREATE_CSVT=YES is going to result in an invalid CSV file
which will mix both the .csvt and .csv content<br>
</p>
<p>Even<br>
</p>
<div>Le 24/04/2023 à 13:34, Moises Calzado via gdal-dev a
écrit :<br>
</div>
<blockquote type="cite">
<div dir="ltr">Hello!
<div><br>
</div>
<div>We're trying to convert a Shapefile into a CSV
using ogr2ogr and we're having some issues while
dealing with some columns that contain line breaks
inside their values. If we have a line with the
following string, ogr2ogr detects that the line break
is a new line and it returns two lines.</div>
<div><br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">"this is my \n
value"</blockquote>
<div><br>
</div>
<div>That's the command that we're executing:</div>
<div><br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">ogr2ogr -f CSV
-skipfailures -makevalid /vsistdout/
/vsizip/shapefile.zip -simplify 0.00001 -dim XY -t_srs
EPSG:4326 -lco GEOMETRY=AS_WKT -lco GEOMETRY_NAME=geom
-lco CREATE_CSVT=YES > result.csv<br>
</blockquote>
<div><br>
</div>
<div>Is this an expected behaviour, or is there any way
to avoid this?</div>
<div>Sharing an example Shapefile so that you can try to
reproduce that behaviour: <a href="https://drive.google.com/file/d/1gFqfTP02KTFoavJyyO-Ix05YwZB2tS24/view?usp=sharing" rel="noreferrer" target="_blank">https://drive.google.com/file/d/1gFqfTP02KTFoavJyyO-Ix05YwZB2tS24/view?usp=sharing</a></div>
<div><br>
</div>
<div>Thanks so much in advance,</div>
<div>Regards.<br clear="all">
<div><br>
</div>
<span>-- </span><br>
<div dir="ltr"> <strong>Moises Calzado</strong>
<p style="margin-bottom:4px;margin-top:4px"> Support
Engineer </p>
<p style="margin-bottom:20px;margin-top:4px">
+34671264286 | <a href="mailto:mcalzado@carto.com" rel="noreferrer" target="_blank">mcalzado@carto.com</a>
| <a href="https://www.carto.com/" rel="nofollow noreferrer" target="_blank">CARTO</a>
</p>
<a href="https://spatial-data-science-conference.com/2023/london/" rel="nofollow noreferrer" target="_blank"> <img src="https://storage.googleapis.com/carto-it-files/signature/SDSC-2023-LND_Signature-mail.jpg" width="516.656px" height="50"> </a> </div>
</div>
</div>
<br>
<fieldset></fieldset>
<pre>_______________________________________________
gdal-dev mailing list
<a href="mailto:gdal-dev@lists.osgeo.org" rel="noreferrer" target="_blank">gdal-dev@lists.osgeo.org</a>
<a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a>
</pre>
</blockquote>
<pre cols="72">--
<a href="http://www.spatialys.com" rel="noreferrer" target="_blank">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
</div>
</blockquote>
</div>
<br clear="all">
<div><br>
</div>
<span>-- </span><br>
<div dir="ltr"> <strong>Moises Calzado</strong>
<p style="margin-bottom:4px;margin-top:4px"> Support Engineer </p>
<p style="margin-bottom:20px;margin-top:4px"> +34671264286 | <a href="mailto:mcalzado@carto.com" rel="noreferrer" target="_blank">mcalzado@carto.com</a>
| <a href="https://www.carto.com/" rel="nofollow noreferrer" target="_blank">CARTO</a> </p>
<a href="https://spatial-data-science-conference.com/2023/london/" rel="nofollow noreferrer" target="_blank"> <img src="https://storage.googleapis.com/carto-it-files/signature/SDSC-2023-LND_Signature-mail.jpg" width="516.656px" height="50"> </a>
</div>
</blockquote>
<pre cols="72">--
<a href="http://www.spatialys.com" rel="noreferrer" target="_blank">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
</div>
</blockquote></div><br clear="all"><div><br></div><span>-- </span><br><div dir="ltr">
<strong>Moises Calzado</strong>
<p style="margin-bottom:4px;margin-top:4px">
Support Engineer
</p>
<p style="margin-bottom:20px;margin-top:4px">
+34671264286 | <a href="mailto:mcalzado@carto.com" rel="noreferrer" target="_blank">mcalzado@carto.com</a>
| <a href="https://www.carto.com/" rel="nofollow noreferrer" target="_blank">CARTO</a>
</p>
<a href="https://spatial-data-science-conference.com/2023/london/" rel="nofollow noreferrer" target="_blank">
<img src="https://storage.googleapis.com/carto-it-files/signature/SDSC-2023-LND_Signature-mail.jpg" height="50" width="516.656px">
</a>
</div>
_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org" rel="noreferrer" target="_blank">gdal-dev@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" rel="noreferrer noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
</blockquote></div>
_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
</blockquote></div><br clear="all"><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature">
<strong>Moises Calzado</strong>
<p style="margin-bottom:4px;margin-top:4px">
Support Engineer
</p>
<p style="margin-bottom:20px;margin-top:4px">
+34671264286 | <a href="mailto:mcalzado@carto.com" target="_blank">mcalzado@carto.com</a>
| <a href="https://www.carto.com/" rel="nofollow" target="_blank">CARTO</a>
</p>
<a href="https://spatial-data-science-conference.com/2023/london/" rel="nofollow" target="_blank">
<img src="https://storage.googleapis.com/carto-it-files/signature/SDSC-2023-LND_Signature-mail.jpg" height="50" width="516.656px">
</a>
</div>