<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
{font-family:Wingdings;
panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:"Segoe UI Emoji";
panose-1:2 11 5 2 4 2 4 2 2 3;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
pre
{mso-style-priority:99;
mso-style-link:"HTML-esimuotoiltu Char";
margin:0cm;
font-size:10.0pt;
font-family:"Courier New";}
span.HTML-esimuotoiltuChar
{mso-style-name:"HTML-esimuotoiltu Char";
mso-style-priority:99;
mso-style-link:HTML-esimuotoiltu;
font-family:Consolas;
mso-fareast-language:FI;}
span.gmailsignatureprefix
{mso-style-name:gmail_signature_prefix;}
span.Shkpostityyli23
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 2.0cm 70.85pt 2.0cm;}
div.WordSection1
{page:WordSection1;}
/* List Definitions */
@list l0
{mso-list-id:830171654;
mso-list-template-ids:1375755278;}
@list l0:level1
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:36.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Symbol;}
@list l0:level2
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:72.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:"Courier New";
mso-bidi-font-family:"Times New Roman";}
@list l0:level3
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:108.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Wingdings;}
@list l0:level4
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:144.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Wingdings;}
@list l0:level5
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:180.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Wingdings;}
@list l0:level6
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:216.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Wingdings;}
@list l0:level7
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:252.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Wingdings;}
@list l0:level8
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:288.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Wingdings;}
@list l0:level9
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:324.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Wingdings;}
@list l1
{mso-list-id:1729644336;
mso-list-template-ids:-2044030620;}
@list l1:level1
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:36.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Symbol;}
@list l1:level2
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:72.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:"Courier New";
mso-bidi-font-family:"Times New Roman";}
@list l1:level3
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:108.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Wingdings;}
@list l1:level4
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:144.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Wingdings;}
@list l1:level5
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:180.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Wingdings;}
@list l1:level6
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:216.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Wingdings;}
@list l1:level7
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:252.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Wingdings;}
@list l1:level8
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:288.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Wingdings;}
@list l1:level9
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:324.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Wingdings;}
ol
{margin-bottom:0cm;}
ul
{margin-bottom:0cm;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="FI" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">Hi,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">Have you considered to output GeoJSONseq
<a href="https://gdal.org/drivers/vector/geojsonseq.html">https://gdal.org/drivers/vector/geojsonseq.html</a> instead of CSV, that for my mind is a workaround as a geodata format. Maybe JSON could handle your newlines by the same.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">-Jukka Rahkonen-<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b>Lähettäjä:</b> gdal-dev <gdal-dev-bounces@lists.osgeo.org>
<b>Puolesta </b>Moises Calzado via gdal-dev<br>
<b>Lähetetty:</b> perjantai 5. toukokuuta 2023 12.32<br>
<b>Vastaanottaja:</b> gdal-dev@lists.osgeo.org<br>
<b>Aihe:</b> Re: [gdal-dev] Ogr2ogr CSV driver not handling correctly line breaks inside columns<o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">Hi Even! <o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I've just created the two issues:<o:p></o:p></p>
<div>
<p class="MsoNormal">- <a href="https://github.com/OSGeo/gdal/issues/7699">https://github.com/OSGeo/gdal/issues/7699</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">- <a href="https://github.com/OSGeo/gdal/issues/7700">https://github.com/OSGeo/gdal/issues/7700</a><o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Robert, as I explained before, we need the `/vsistdout/` driver as we're processing the file in streaming mode, so we can't save the result to the storage.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Unforteunately, the problem arises when using that driver.<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">El jue, 4 may 2023 a las 15:39, Even Rouault (<<a href="mailto:even.rouault@spatialys.com">even.rouault@spatialys.com</a>>) escribió:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<p>Moises,<o:p></o:p></p>
<p>please fild 2 issues in the github issue tracker:<o:p></o:p></p>
<p>- one about /vsistdout/ where .csvt and .prj content shouldn't be emitted<o:p></o:p></p>
<p>- one about decoupling the layer GEOMETRY_NAME creation option with CREATE_CSVT=YES<o:p></o:p></p>
<p>Even<o:p></o:p></p>
<div>
<p class="MsoNormal">Le 04/05/2023 à 13:58, Moises Calzado via gdal-dev a écrit :<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal">Hi Robert! <o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I think that we're losing a bit the main issue that we reported, as in fact the problem is related with line breaks in the output generated while using /vsistdout and the CREATE_CSVT=YES option.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Even pointed out that avoiding that flag it works as expected, but when it's used the generated output is not okay as the "Fields with embedded line breaks must be quoted" rule is not followed.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">IMHO although the generated output is not a CSV itself, we should be able to delete the first two lines (projection info and types) and deal with the rest of the content as a CSV.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">What we're doing is streaming the output of the /vsistdout driver to another process that perform some steps with the resultant CSV. In all cases it works correctly, as the output of the ogr2ogr execution is a valid CSV when deleting the
first two lines, but in the case reported in my first email it's not.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">The CREATE_CSVT=YES option is mandatory for us as for the moment, it's requires to use the GEOMETRY_NAME=<b>geom
</b>one, so we don't have any workaround.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Just wanted to confirm if that's expected for you (generating an output that it's not a valid CSV in the end)!<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">El mié, 3 may 2023 a las 21:05, Robert Hewlett (<<a href="mailto:rob.hewy@gmail.com" target="_blank">rob.hewy@gmail.com</a>>) escribió:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p class="MsoNormal">Hi,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I just tested with : GDAL 3.6.4, released 2023/04/17<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Using the ogr2ogr as follows:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">ogr2ogr -f CSV poi_out.csv poi.shp -lco CREATE_CSVT=YES<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">I get three files but no geometry<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">ogr2ogr -f CSV poi_out.csv poi.shp -lco CREATE_CSVT=YES -lco GEOMETRY=AS_WKT<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">I get three file with the geometry as WKT with the column name WKT<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><b>WKT</b>,id,poi_name,poi_types<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">"POINT (508878.602179846 5433913.2763688)","1",crescent,"4"<br>
"POINT (517836.918121302 5447702.01715829)","2",Tynehead Regional Park,"1"<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">ogr2ogr -f CSV poi_out.csv poi.shp -lco CREATE_CSVT=YES -lco GEOMETRY=AS_WKT -lco GEOMETRY_NAME=<b>geom</b><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">I get three file with the geometry as WKT but the column called
<b>geom</b><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><b>geom</b>,id,poi_name,poi_types<br>
"POINT (508878.602179846 5433913.2763688)","1",crescent,"4"<br>
"POINT (517836.918121302 5447702.01715829)","2",Tynehead Regional Park,"1"<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">What does<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><b>ogr2ogr --version </b><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">report back<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Wed, May 3, 2023 at 9:38 AM Robert Hewlett <<a href="mailto:rob.hewy@gmail.com" target="_blank">rob.hewy@gmail.com</a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<p class="MsoNormal">Hi, <o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Not to start a controversy but it feels like the standard hints at three files. Did the standard change?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">If it is three files which works for me in QGIS and geopandas i.e. data lands where it is suppose to, then more layer creations options are needed to handle the SRID/CRS<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">CREATE_PRJ=YES/NO<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">or -t_srs and/or -s_srs triggers the dot-prj file being created.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Just saying <span style="font-family:"Segoe UI Emoji",sans-serif">
😊</span>.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">In the meantime would a short python script help parse the one file into three?<o:p></o:p></p>
</div>
<div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Wed, May 3, 2023 at 9:16 AM Moises Calzado via gdal-dev <<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<p class="MsoNormal">Hi Robert, <o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Yes, we're getting one with all the info!<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">El mié, 3 may 2023 a las 18:14, Robert Hewlett (<<a href="mailto:rob.hewy@gmail.com" target="_blank">rob.hewy@gmail.com</a>>) escribió:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">Just to clarify, instead of getting three files you are getting one with all the info: types, projection, data?<o:p></o:p></p>
</div>
<p class="MsoNormal"><a href="https://giswiki.hsr.ch/GeoCSV" target="_blank">https://giswiki.hsr.ch/GeoCSV</a><o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Wed, May 3, 2023 at 8:57 AM Moises Calzado via gdal-dev <<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<p class="MsoNormal">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.
<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">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.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">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.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Probably we're losing something, but as we see it, the generated CSV should be a valid one. Does that make sense?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Thanks so much for your help!<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">El mié, 3 may 2023 a las 15:10, Robert Hewlett (<<a href="mailto:rob.hewy@gmail.com" target="_blank">rob.hewy@gmail.com</a>>) escribió:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<p class="MsoNormal">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. <o:p></o:p></p>
<div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I hope that makes sense.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">CSVT<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Integer, Integer,WKT<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">CSV<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">line_id,point_id,geom<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">1,1,"POINT(1000 1000)"<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">PRJ<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">EPSG:26910<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">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:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<p class="MsoNormal">Hi Even, <o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Thanks so much for taking a look into that one!<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">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:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<p style="mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:0cm;margin-left:54.0pt;text-indent:-18.0pt;line-height:18.0pt;mso-list:l1 level1 lfo1;box-sizing:border-box">
<![if !supportLists]><span style="font-size:10.0pt;font-family:Symbol"><span style="mso-list:Ignore">·<span style="font:7.0pt "Times New Roman"">
</span></span></span><![endif]><b>GEOMETRY_NAME</b>=name (Starting with GDAL 2.1): Name of geometry column. Only used if GEOMETRY=AS_WKT and CREATE_CSVT=YES. Defaults to WKT<o:p></o:p></p>
</blockquote>
<div>
<p class="MsoNormal">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?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">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.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Could you please shed some light on this?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Looking forward to your reply,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Regards.<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">El mié, 3 may 2023 a las 14:00, Even Rouault (<<a href="mailto:even.rouault@spatialys.com" target="_blank">even.rouault@spatialys.com</a>>) escribió:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<p>you didn't post to the list<o:p></o:p></p>
<div>
<p class="MsoNormal">Le 03/05/2023 à 13:49, Moises Calzado a écrit :<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal">Hi Even, <o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Thanks so much for taking a look into that one!<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">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:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<p style="mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:0cm;margin-left:54.0pt;text-indent:-18.0pt;line-height:18.0pt;mso-list:l0 level1 lfo2;box-sizing:border-box">
<![if !supportLists]><span style="font-size:10.0pt;font-family:Symbol"><span style="mso-list:Ignore">·<span style="font:7.0pt "Times New Roman"">
</span></span></span><![endif]><b>GEOMETRY_NAME</b>=name (Starting with GDAL 2.1): Name of geometry column. Only used if GEOMETRY=AS_WKT and CREATE_CSVT=YES. Defaults to WKT<o:p></o:p></p>
</blockquote>
<div>
<p class="MsoNormal">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?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">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.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Could you please shed some light on this?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Looking forward to your reply,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Regards.<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">El sáb, 29 abr 2023 a las 15:44, Even Rouault (<<a href="mailto:even.rouault@spatialys.com" target="_blank">even.rouault@spatialys.com</a>>) escribió:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<p>Moises,<o:p></o:p></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.<o:p></o:p></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" target="_blank">
https://en.wikipedia.org/wiki/Comma-separated_values</a><o:p></o:p></p>
<p>$ ogr2ogr out.csv /vsizip/dataframe.zip<o:p></o:p></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<o:p></o:p></p>
<p style="margin-bottom:12.0pt">$ 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<o:p></o:p></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<o:p></o:p></p>
<p>Even<o:p></o:p></p>
<div>
<p class="MsoNormal">Le 24/04/2023 à 13:34, Moises Calzado via gdal-dev a écrit :<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal">Hello! <o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">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.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<p class="MsoNormal">"this is my \n value"<o:p></o:p></p>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">That's the command that we're executing:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<p class="MsoNormal">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<o:p></o:p></p>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Is this an expected behaviour, or is there any way to avoid this?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">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" target="_blank">
https://drive.google.com/file/d/1gFqfTP02KTFoavJyyO-Ix05YwZB2tS24/view?usp=sharing</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Thanks so much in advance,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Regards.<br clear="all">
<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal">-- <o:p></o:p></p>
<div>
<p class="MsoNormal"><strong><span style="font-family:"Calibri",sans-serif">Moises Calzado</span></strong>
<o:p></o:p></p>
<p style="mso-margin-top-alt:3.0pt;margin-right:0cm;margin-bottom:3.0pt;margin-left:0cm">
Support Engineer <o:p></o:p></p>
<p style="mso-margin-top-alt:3.0pt;margin-right:0cm;margin-bottom:15.0pt;margin-left:0cm">
+34671264286 | <a href="mailto:mcalzado@carto.com" target="_blank">mcalzado@carto.com</a> |
<a href="https://www.carto.com/" target="_blank">CARTO</a> <o:p></o:p></p>
<p class="MsoNormal"><a href="https://spatial-data-science-conference.com/2023/london/" target="_blank"><span style="text-decoration:none"><img border="0" width="517" height="50" style="width:5.3819in;height:.5208in" id="_x0000_i1031" src="https://storage.googleapis.com/carto-it-files/signature/SDSC-2023-LND_Signature-mail.jpg"></span></a><o:p></o:p></p>
</div>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<pre>_______________________________________________<o:p></o:p></pre>
<pre>gdal-dev mailing list<o:p></o:p></pre>
<pre><a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a><o:p></o:p></pre>
<pre><a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a><o:p></o:p></pre>
</blockquote>
<pre>-- <o:p></o:p></pre>
<pre><a href="http://www.spatialys.com/" target="_blank">http://www.spatialys.com</a><o:p></o:p></pre>
<pre>My software is free, but my time generally not.<o:p></o:p></pre>
</div>
</blockquote>
</div>
<p class="MsoNormal"><br clear="all">
<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal">-- <o:p></o:p></p>
<div>
<p class="MsoNormal"><strong><span style="font-family:"Calibri",sans-serif">Moises Calzado</span></strong>
<o:p></o:p></p>
<p style="mso-margin-top-alt:3.0pt;margin-right:0cm;margin-bottom:3.0pt;margin-left:0cm">
Support Engineer <o:p></o:p></p>
<p style="mso-margin-top-alt:3.0pt;margin-right:0cm;margin-bottom:15.0pt;margin-left:0cm">
+34671264286 | <a href="mailto:mcalzado@carto.com" target="_blank">mcalzado@carto.com</a> |
<a href="https://www.carto.com/" target="_blank">CARTO</a> <o:p></o:p></p>
<p class="MsoNormal"><a href="https://spatial-data-science-conference.com/2023/london/" target="_blank"><span style="text-decoration:none"><img border="0" width="517" height="50" style="width:5.3819in;height:.5208in" id="_x0000_i1030" src="https://storage.googleapis.com/carto-it-files/signature/SDSC-2023-LND_Signature-mail.jpg"></span></a><o:p></o:p></p>
</div>
</blockquote>
<pre>-- <o:p></o:p></pre>
<pre><a href="http://www.spatialys.com/" target="_blank">http://www.spatialys.com</a><o:p></o:p></pre>
<pre>My software is free, but my time generally not.<o:p></o:p></pre>
</div>
</blockquote>
</div>
<p class="MsoNormal"><br clear="all">
<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal">-- <o:p></o:p></p>
<div>
<p class="MsoNormal"><strong><span style="font-family:"Calibri",sans-serif">Moises Calzado</span></strong>
<o:p></o:p></p>
<p style="mso-margin-top-alt:3.0pt;margin-right:0cm;margin-bottom:3.0pt;margin-left:0cm">
Support Engineer <o:p></o:p></p>
<p style="mso-margin-top-alt:3.0pt;margin-right:0cm;margin-bottom:15.0pt;margin-left:0cm">
+34671264286 | <a href="mailto:mcalzado@carto.com" target="_blank">mcalzado@carto.com</a> |
<a href="https://www.carto.com/" target="_blank">CARTO</a> <o:p></o:p></p>
<p class="MsoNormal"><a href="https://spatial-data-science-conference.com/2023/london/" target="_blank"><span style="text-decoration:none"><img border="0" width="517" height="50" style="width:5.3819in;height:.5208in" id="_x0000_i1029" src="https://storage.googleapis.com/carto-it-files/signature/SDSC-2023-LND_Signature-mail.jpg"></span></a><o:p></o:p></p>
</div>
<p class="MsoNormal">_______________________________________________<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" target="_blank">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a><o:p></o:p></p>
</blockquote>
</div>
<p class="MsoNormal">_______________________________________________<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" target="_blank">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a><o:p></o:p></p>
</blockquote>
</div>
<p class="MsoNormal"><br clear="all">
<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal">-- <o:p></o:p></p>
<div>
<p class="MsoNormal"><strong><span style="font-family:"Calibri",sans-serif">Moises Calzado</span></strong>
<o:p></o:p></p>
<p style="mso-margin-top-alt:3.0pt;margin-right:0cm;margin-bottom:3.0pt;margin-left:0cm">
Support Engineer <o:p></o:p></p>
<p style="mso-margin-top-alt:3.0pt;margin-right:0cm;margin-bottom:15.0pt;margin-left:0cm">
+34671264286 | <a href="mailto:mcalzado@carto.com" target="_blank">mcalzado@carto.com</a> |
<a href="https://www.carto.com/" target="_blank">CARTO</a> <o:p></o:p></p>
<p class="MsoNormal"><a href="https://spatial-data-science-conference.com/2023/london/" target="_blank"><span style="text-decoration:none"><img border="0" width="517" height="50" style="width:5.3819in;height:.5208in" id="_x0000_i1028" src="https://storage.googleapis.com/carto-it-files/signature/SDSC-2023-LND_Signature-mail.jpg"></span></a><o:p></o:p></p>
</div>
<p class="MsoNormal">_______________________________________________<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" target="_blank">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a><o:p></o:p></p>
</blockquote>
</div>
<p class="MsoNormal">_______________________________________________<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" target="_blank">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a><o:p></o:p></p>
</blockquote>
</div>
<p class="MsoNormal"><br clear="all">
<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal">-- <o:p></o:p></p>
<div>
<p class="MsoNormal"><strong><span style="font-family:"Calibri",sans-serif">Moises Calzado</span></strong>
<o:p></o:p></p>
<p style="mso-margin-top-alt:3.0pt;margin-right:0cm;margin-bottom:3.0pt;margin-left:0cm">
Support Engineer <o:p></o:p></p>
<p style="mso-margin-top-alt:3.0pt;margin-right:0cm;margin-bottom:15.0pt;margin-left:0cm">
+34671264286 | <a href="mailto:mcalzado@carto.com" target="_blank">mcalzado@carto.com</a> |
<a href="https://www.carto.com/" target="_blank">CARTO</a> <o:p></o:p></p>
<p class="MsoNormal"><a href="https://spatial-data-science-conference.com/2023/london/" target="_blank"><span style="text-decoration:none"><img border="0" width="517" height="50" style="width:5.3819in;height:.5208in" id="_x0000_i1027" src="https://storage.googleapis.com/carto-it-files/signature/SDSC-2023-LND_Signature-mail.jpg"></span></a><o:p></o:p></p>
</div>
<p class="MsoNormal">_______________________________________________<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" target="_blank">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a><o:p></o:p></p>
</blockquote>
</div>
</blockquote>
</div>
<p class="MsoNormal">_______________________________________________<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" target="_blank">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a><o:p></o:p></p>
</blockquote>
</div>
<p class="MsoNormal"><br clear="all">
<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal">-- <o:p></o:p></p>
<div>
<p class="MsoNormal"><strong><span style="font-family:"Calibri",sans-serif">Moises Calzado</span></strong>
<o:p></o:p></p>
<p style="mso-margin-top-alt:3.0pt;margin-right:0cm;margin-bottom:3.0pt;margin-left:0cm">
Support Engineer <o:p></o:p></p>
<p style="mso-margin-top-alt:3.0pt;margin-right:0cm;margin-bottom:15.0pt;margin-left:0cm">
+34671264286 | <a href="mailto:mcalzado@carto.com" target="_blank">mcalzado@carto.com</a> |
<a href="https://www.carto.com/" target="_blank">CARTO</a> <o:p></o:p></p>
<p class="MsoNormal"><a href="https://spatial-data-science-conference.com/2023/london/" target="_blank"><span style="text-decoration:none"><img border="0" width="517" height="50" style="width:5.3819in;height:.5208in" id="_x0000_i1026" src="https://storage.googleapis.com/carto-it-files/signature/SDSC-2023-LND_Signature-mail.jpg"></span></a><o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<pre>_______________________________________________<o:p></o:p></pre>
<pre>gdal-dev mailing list<o:p></o:p></pre>
<pre><a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a><o:p></o:p></pre>
<pre><a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a><o:p></o:p></pre>
</blockquote>
<pre>-- <o:p></o:p></pre>
<pre><a href="http://www.spatialys.com/" target="_blank">http://www.spatialys.com</a><o:p></o:p></pre>
<pre>My software is free, but my time generally not.<o:p></o:p></pre>
</div>
</blockquote>
</div>
<p class="MsoNormal"><br clear="all">
<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal"><span class="gmailsignatureprefix">-- </span><o:p></o:p></p>
<div>
<p class="MsoNormal"><strong><span style="font-family:"Calibri",sans-serif">Moises Calzado</span></strong>
<o:p></o:p></p>
<p style="mso-margin-top-alt:3.0pt;margin-right:0cm;margin-bottom:3.0pt;margin-left:0cm">
Support Engineer <o:p></o:p></p>
<p style="mso-margin-top-alt:3.0pt;margin-right:0cm;margin-bottom:15.0pt;margin-left:0cm">
+34671264286 | <a href="mailto:mcalzado@carto.com" target="_blank">mcalzado@carto.com</a> |
<a href="https://www.carto.com/" target="_blank">CARTO</a> <o:p></o:p></p>
<p class="MsoNormal"><a href="https://spatial-data-science-conference.com/2023/london/" target="_blank"><span style="text-decoration:none"><img border="0" width="517" height="50" style="width:5.3819in;height:.5208in" id="_x0000_i1025" src="https://storage.googleapis.com/carto-it-files/signature/SDSC-2023-LND_Signature-mail.jpg"></span></a><o:p></o:p></p>
</div>
</div>
</body>
</html>