<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Location Update through CSV file using Python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/location-update-through-csv-file-using-python/m-p/1377519#M69775</link>
    <description>&lt;P&gt;Your script (with proper indentation) works for me! Check the attribute table to confirm features are being created. Also check if you switched longitude and latitude values (I know I did and my point initially ended up in Antarctica &lt;span class="lia-unicode-emoji" title=":grinning_face_with_sweat:"&gt;😅&lt;/span&gt;)&lt;/P&gt;</description>
    <pubDate>Fri, 02 Feb 2024 13:38:10 GMT</pubDate>
    <dc:creator>Raul</dc:creator>
    <dc:date>2024-02-02T13:38:10Z</dc:date>
    <item>
      <title>Location Update through CSV file using Python</title>
      <link>https://community.esri.com/t5/python-questions/location-update-through-csv-file-using-python/m-p/1377477#M69773</link>
      <description>&lt;P&gt;I want to update a location using a csv file, the sender will send his location in a csv file and at the receiver end i will be running a python script to check any incoming received file in my folder as soon as a new file comes in the received folder the location will be automatically updated. the code written for this is as under.&lt;/P&gt;&lt;P&gt;import arcpy&lt;BR /&gt;import pandas as pd&lt;BR /&gt;import os&lt;BR /&gt;from glob import glob&lt;/P&gt;&lt;P&gt;# Base path for CSV files&lt;BR /&gt;base_csv_path = r"C:\Users\saim\Desktop\EthCom_V_3.21\ReceivedFiles"&lt;/P&gt;&lt;P&gt;# Feature layer path&lt;BR /&gt;feature_layer_path = r"C:\Users\saim\Documents\ArcGIS\Projects\MyProject3\MyProject3.gdb\Yesss"&lt;/P&gt;&lt;P&gt;# Function to update feature layer with points from a CSV file&lt;BR /&gt;def update_feature_layer(csv_file_path):&lt;BR /&gt;timestamp_column = "Timestamp"&lt;BR /&gt;lat_column = "Latitude"&lt;BR /&gt;lon_column = "Longitude"&lt;BR /&gt;altitude_column = "Altitude"&lt;/P&gt;&lt;P&gt;# Read CSV data&lt;BR /&gt;data = pd.read_csv(csv_file_path)&lt;/P&gt;&lt;P&gt;# Create a spatial reference object for WGS84 (latitude and longitude coordinates)&lt;BR /&gt;spatial_reference = arcpy.SpatialReference(4326)&lt;/P&gt;&lt;P&gt;# Create PointGeometry objects&lt;BR /&gt;point_array = [arcpy.PointGeometry(arcpy.Point(float(lon), float(lat)), spatial_reference) for lat, lon in zip(data[lat_column], data[lon_column])]&lt;/P&gt;&lt;P&gt;# Insert points into the feature layer&lt;BR /&gt;with arcpy.da.InsertCursor(feature_layer_path, ["SHAPE@"]) as cursor:&lt;BR /&gt;for point in point_array:&lt;BR /&gt;cursor.insertRow([point])&lt;/P&gt;&lt;P&gt;print(f"Updated feature layer with data from {csv_file_path}")&lt;/P&gt;&lt;P&gt;# List of receivers&lt;BR /&gt;receivers = ["truck_1", "truck_2", "truck_3"]&lt;/P&gt;&lt;P&gt;# Loop through receivers and update the feature layer with the latest CSV file&lt;BR /&gt;for receiver in receivers:&lt;BR /&gt;search_pattern = os.path.join(base_csv_path, f"{receiver}*.csv")&lt;BR /&gt;latest_csv_file = max(glob(search_pattern), key=os.path.getctime, default=None)&lt;/P&gt;&lt;P&gt;if latest_csv_file:&lt;BR /&gt;update_feature_layer(latest_csv_file)&lt;BR /&gt;print(f"Updated feature layer with data from {latest_csv_file}")&lt;BR /&gt;else:&lt;BR /&gt;print(f"No CSV file found for {receiver}")&lt;BR /&gt;&lt;BR /&gt;but the issue is that the code successfully runs but there is no point being shown on the map. nothing is visible on the layer created for it&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2024 09:35:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/location-update-through-csv-file-using-python/m-p/1377477#M69773</guid>
      <dc:creator>MariaJutt</dc:creator>
      <dc:date>2024-02-02T09:35:04Z</dc:date>
    </item>
    <item>
      <title>Re: Location Update through CSV file using Python</title>
      <link>https://community.esri.com/t5/python-questions/location-update-through-csv-file-using-python/m-p/1377482#M69774</link>
      <description>&lt;P&gt;&lt;A href="https://community.esri.com/t5/python-blog/code-formatting-the-community-version/ba-p/1007633" target="_blank"&gt;Code formatting ... the Community Version - Esri Community&lt;/A&gt;&lt;/P&gt;&lt;P&gt;to facilitate reading and to provide line numbers&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2024 10:11:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/location-update-through-csv-file-using-python/m-p/1377482#M69774</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2024-02-02T10:11:50Z</dc:date>
    </item>
    <item>
      <title>Re: Location Update through CSV file using Python</title>
      <link>https://community.esri.com/t5/python-questions/location-update-through-csv-file-using-python/m-p/1377519#M69775</link>
      <description>&lt;P&gt;Your script (with proper indentation) works for me! Check the attribute table to confirm features are being created. Also check if you switched longitude and latitude values (I know I did and my point initially ended up in Antarctica &lt;span class="lia-unicode-emoji" title=":grinning_face_with_sweat:"&gt;😅&lt;/span&gt;)&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2024 13:38:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/location-update-through-csv-file-using-python/m-p/1377519#M69775</guid>
      <dc:creator>Raul</dc:creator>
      <dc:date>2024-02-02T13:38:10Z</dc:date>
    </item>
  </channel>
</rss>

