<div dir="ltr" gmail_original="1">Another option is to use the tool 'Create Points Layer from Table' tool from QGIS Processing Toolbox. This tool can read a CSV and create a point layer (i.e. shapefile). First test it on a single file and if it works for your use case, you can click the 'Run as a Batch Process' and run it on all files in your folder.<div><br clear="all"><div><div dir="ltr" class="gmail_signature"><div dir="ltr">---<div>Ujaval Gandhi</div><div>Spatial Thoughts</div><div><a href="http://www.spatialthoughts.com" target="_blank">www.spatialthoughts.com</a></div><div><br></div></div></div></div><br></div></div><br><img width="0" height="0" class="mailtrack-img" alt="" style="display:flex" src="https://mailtrack.io/trace/mail/w/cWdpcy11c2VyQGxpc3RzLm9zZ2VvLm9yZw==/a83d0c4e1d4abd90615995595c03af217a5cf1c0.png?u=8747767" ><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Nov 16, 2022 at 3:04 AM Salvatore Mellino via Qgis-user <qgis-user@lists.osgeo.org> 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="auto"><div dir="ltr"></div><div dir="ltr">I found this on line :</div><div dir="ltr"><pre style="margin-top: 0px; border: 0px; font-stretch: inherit; vertical-align: baseline; box-sizing: inherit; width: auto; max-height: 600px; overflow: auto;"><code style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; box-sizing: inherit; white-space: inherit;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; font-size: 13px; vertical-align: baseline; box-sizing: inherit;"><br></span></code></pre><pre style="margin-top: 0px; border: 0px; font-stretch: inherit; vertical-align: baseline; box-sizing: inherit; width: auto; max-height: 600px; overflow: auto;"><code style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; box-sizing: inherit; white-space: inherit;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; font-size: 13px; vertical-align: baseline; box-sizing: inherit;">import</span> glob, os
<span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; font-size: 13px; vertical-align: baseline; box-sizing: inherit;"># Define path to directory of your csv files</span>
path_to_csv = <span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; font-size: 13px; vertical-align: baseline; box-sizing: inherit;">"C:/File Path/"</span>
<span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; font-size: 13px; vertical-align: baseline; box-sizing: inherit;"># Set current directory to path of csv files</span>
os.chdir(path_to_csv)
<span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; font-size: 13px; vertical-align: baseline; box-sizing: inherit;"># Find each .csv file and load them as vector layers</span>
<span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; font-size: 13px; vertical-align: baseline; box-sizing: inherit;">for</span> fname <span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; font-size: 13px; vertical-align: baseline; box-sizing: inherit;">in</span> glob.glob(<span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; font-size: 13px; vertical-align: baseline; box-sizing: inherit;">"*.csv"</span>):
uri =<span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; font-size: 13px; vertical-align: baseline; box-sizing: inherit;">"file:///"</span>+path_to_csv + fname+<span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; font-size: 13px; vertical-align: baseline; box-sizing: inherit;">"encoding=%s&delimiter=%<wbr>s&xField=%s&yField=%s&crs=%s"</span> % (<span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; font-size: 13px; vertical-align: baseline; box-sizing: inherit;">"UTF-8"</span>,<span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; font-size: 13px; vertical-align: baseline; box-sizing: inherit;">","</span>, <span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; font-size: 13px; vertical-align: baseline; box-sizing: inherit;">"Long"</span>, <span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; font-size: 13px; vertical-align: baseline; box-sizing: inherit;">"Lat"</span>,<span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; font-size: 13px; vertical-align: baseline; box-sizing: inherit;">"epsg:4326"</span>)
name=fname.replace(<span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; font-size: 13px; vertical-align: baseline; box-sizing: inherit;">'.csv'</span>, <span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; font-size: 13px; vertical-align: baseline; box-sizing: inherit;">''</span>)
lyr = QgsVectorLayer(uri, name, <span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; font-size: 13px; vertical-align: baseline; box-sizing: inherit;">'delimitedtext'</span>)
QgsProject.instance().<wbr>addMapLayer(lyr)</code></pre><pre style="margin-top: 0px; border: 0px; font-stretch: inherit; vertical-align: baseline; box-sizing: inherit; width: auto; max-height: 600px; overflow: auto;"><code style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; box-sizing: inherit; white-space: inherit;"><br></code></pre><pre style="margin-top: 0px; border: 0px; font-stretch: inherit; vertical-align: baseline; box-sizing: inherit; width: auto; max-height: 600px; overflow: auto;"><code style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant-caps: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; box-sizing: inherit; white-space: inherit;">but it doesn’t work. I have csv files with lat long and value separated by space and without header </code></pre></div><div dir="ltr"><br><blockquote type="cite">Il giorno 15 nov 2022, alle ore 21:22, Hugh Kelley <<a href="mailto:hghklly@gmail.com" target="_blank">hghklly@gmail.com</a>> ha scritto:<br><br></blockquote></div><blockquote type="cite"><div dir="ltr"><div dir="ltr">Awesome thanks very much. glad I asked, you learn something new every day.<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Nov 15, 2022 at 3:19 PM David Strip <<a href="mailto:qgis-user@stripfamily.net" target="_blank">qgis-user@stripfamily.net</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>
<div>Starting with v2.1, ogr2ogr supports
args X_POSSIBLE_NAMES, Y_POSSIBLE_NAMES which are strings with
allowed wildcards (eg, Lon* ), or you can use field_1, field_2,
etc to explicitly give the position of lat/lon.<br>
It's explained on the <a href="https://gdal.org/drivers/vector/csv.html" target="_blank">driver page.</a>
This <a href="https://gis.stackexchange.com/a/276607/4449" target="_blank">StackExchange
</a>post shows csv to shapefile conversion and included Windows
command line syntax for looping over files in a directory.<br>
<br>
On 11/15/2022 12:58 PM, Hugh Kelley wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">
<div>David, this was my first thought when i saw this question
as well.</div>
<div><br>
</div>
<div>however, I didn't look for very long but I haven't seen a
way to tell ogr2ogr to read columns in a csv as the lat/lon
and write those as points to the shapefile. I generally write
a csv to postgres as a non-spatial table and then process the
lat lon columns with postgis. <br>
</div>
<div><br>
</div>
<div> Are there arguments for ogr2ogr that can do this?</div>
</div>
</blockquote>
<br>
</div>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr">Hugh Kelley <br><div><br></div></div></div></div></div></div></div></div>
</div></blockquote></div>______________________________<wbr>_________________<br>
Qgis-user mailing list<br>
<a href="mailto:Qgis-user@lists.osgeo.org" target="_blank">Qgis-user@lists.osgeo.org</a><br>
List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailma<wbr>n/listinfo/qgis-user</a><br>
Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailma<wbr>n/listinfo/qgis-user</a><br>
</blockquote></div>