<?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: python script tool - need to join csv in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-script-tool-need-to-join-csv/m-p/1599174#M73957</link>
    <description>&lt;P&gt;Does the first row of the csv contain the field names?&lt;/P&gt;&lt;P&gt;Can you post a few rows to see if there is something wrong with the csv?&lt;/P&gt;</description>
    <pubDate>Tue, 25 Mar 2025 19:29:32 GMT</pubDate>
    <dc:creator>DanPatterson</dc:creator>
    <dc:date>2025-03-25T19:29:32Z</dc:date>
    <item>
      <title>python script tool - need to join csv</title>
      <link>https://community.esri.com/t5/python-questions/python-script-tool-need-to-join-csv/m-p/1599017#M73954</link>
      <description>&lt;P&gt;I am building a toolbox. I am stuck at the last step in my python script tool. I have csv file located outside the project folder (outside ArcGIS env). I need to join the csv to a featureclass in the project. I have tried&amp;nbsp;arcpy.management.AddJoin() method to directly join the csv table to fc, but that doesn't work; I assume because the csv table is outside ArcGIS env.&lt;/P&gt;&lt;P&gt;Then I tried to convert the csv to dBase using&amp;nbsp;TableToDBASE_conversion and&amp;nbsp;TableToTable_conversion to see if that works, but the conversion is not happening, seemingly the input csv table cannot be read:&lt;/P&gt;&lt;P&gt;ERROR 000735:&lt;SPAN class=""&gt; Input Rows: Value is required&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyhow, the objective is to join the csv table from outside ArcGIS to the featureclass.&lt;/P&gt;&lt;P&gt;Is there a straightforward way to accomplishing this task by relying on arcpy and os libraries? I have seen a suggestion of geopandas but I do not want a geopandas based solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code I have...&lt;/P&gt;&lt;P&gt;# set the environment variables&lt;BR /&gt;arcpy.env.overwriteOutput = True&lt;BR /&gt;arcpy.env.workspace = gdb&lt;/P&gt;&lt;P&gt;# Export Table conversion for bringing the table into ArcGIS&lt;BR /&gt;arcTable = arcpy.TableToDBASE_conversion(Input_Table=t, Output_Folder=folder)&lt;/P&gt;&lt;P&gt;# t is a pandas dataframe that is exported to_csv()&lt;BR /&gt;&lt;BR /&gt;# Process to creating a new layer&lt;BR /&gt;s = arcpy.management.AddJoin(in_layer_or_view=appropriate_shapefile&lt;BR /&gt;,in_field=Join_Field_on_Shapefile&lt;BR /&gt;,join_table=arcTable&lt;BR /&gt;,join_field='UID'&lt;BR /&gt;,join_type='KEEP_COMMON')&lt;BR /&gt;arcpy.conversion.ExportFeatures(s, layer_name)&lt;BR /&gt;arcpy.management.RemoveJoin(s)&lt;/P&gt;</description>
      <pubDate>Tue, 25 Mar 2025 15:26:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-tool-need-to-join-csv/m-p/1599017#M73954</guid>
      <dc:creator>Seyed-MahdySadraddini</dc:creator>
      <dc:date>2025-03-25T15:26:41Z</dc:date>
    </item>
    <item>
      <title>Re: python script tool - need to join csv</title>
      <link>https://community.esri.com/t5/python-questions/python-script-tool-need-to-join-csv/m-p/1599042#M73955</link>
      <description>&lt;P&gt;The join feature has be converted into a feature layer (arcpy.management.MakeFeatureLayer(shapefile, feature_layer) prior to joining.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;# Create a feature layer from the shapefile
arcpy.management.MakeFeatureLayer(shapefile, feature_layer)

# Perform the join
joined_layer = arcpy.management.AddJoin(
    in_layer_or_view=feature_layer,  # Use the feature layer here
    in_field=Join_Field_on_Shapefile,
    join_table=csv_table,
    join_field='UID',
    join_type='KEEP_COMMON'
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Mar 2025 15:53:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-tool-need-to-join-csv/m-p/1599042#M73955</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2025-03-25T15:53:07Z</dc:date>
    </item>
    <item>
      <title>Re: python script tool - need to join csv</title>
      <link>https://community.esri.com/t5/python-questions/python-script-tool-need-to-join-csv/m-p/1599135#M73956</link>
      <description>&lt;P&gt;Thanks for the suggestion. I added the feature layer. But I think the issue at hand is the fact that csv file from outside ArcGIS env is not read properly. I got ERROR 000735 again!&lt;/P&gt;&lt;P&gt;I modified the script by reading the csv file into in-memory dataframe (table2) in pandas. Value Error is raised saying:&amp;nbsp;&lt;SPAN class=""&gt;Invalid file path or buffer object type: &amp;lt;class 'NoneType'&amp;gt;. I know that somehow I have to modify the csv table outside ArcGIS within the ArcGIS env. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;If I was using ArcGIS GUI, then I would drag and drop the csv into table of contents. I know I need to do something similar so the csv file is readable by feature classes (inside ArcGIS env).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;How should I proceed with this problem?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;t = table.to_csv(os.path.join(folder, f'{table_name}.csv'), index=False)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# set the environmental variables&lt;BR /&gt;arcpy.env.overwriteOutput = True&lt;BR /&gt;arcpy.env.workspace = gdb&lt;/P&gt;&lt;P&gt;# Read csv into dataframe&lt;BR /&gt;table2 = pd.read_csv(t)&lt;BR /&gt;&lt;BR /&gt;# Process to creating a new layer&lt;BR /&gt;# Create a feature layer from the shapefile&lt;BR /&gt;arcpy.management.MakeFeatureLayer(appropriate_shapefile, layer_name)&lt;/P&gt;&lt;P&gt;# Join data and export&lt;BR /&gt;s = arcpy.management.AddJoin(in_layer_or_view=layer_name&lt;BR /&gt;,in_field=Join_Field_on_Shapefile&lt;BR /&gt;,join_table=table2&lt;BR /&gt;,join_field='UID'&lt;BR /&gt;,join_type='KEEP_COMMON')&lt;BR /&gt;arcpy.conversion.ExportFeatures(s, layer_name)&lt;/P&gt;</description>
      <pubDate>Tue, 25 Mar 2025 17:45:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-tool-need-to-join-csv/m-p/1599135#M73956</guid>
      <dc:creator>Seyed-MahdySadraddini</dc:creator>
      <dc:date>2025-03-25T17:45:38Z</dc:date>
    </item>
    <item>
      <title>Re: python script tool - need to join csv</title>
      <link>https://community.esri.com/t5/python-questions/python-script-tool-need-to-join-csv/m-p/1599174#M73957</link>
      <description>&lt;P&gt;Does the first row of the csv contain the field names?&lt;/P&gt;&lt;P&gt;Can you post a few rows to see if there is something wrong with the csv?&lt;/P&gt;</description>
      <pubDate>Tue, 25 Mar 2025 19:29:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-tool-need-to-join-csv/m-p/1599174#M73957</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2025-03-25T19:29:32Z</dc:date>
    </item>
    <item>
      <title>Re: python script tool - need to join csv</title>
      <link>https://community.esri.com/t5/python-questions/python-script-tool-need-to-join-csv/m-p/1599225#M73958</link>
      <description>&lt;P&gt;Have you tried converting the csv file with arcpy.conversion.TableToTable prior to the join?&lt;/P&gt;</description>
      <pubDate>Tue, 25 Mar 2025 21:53:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-tool-need-to-join-csv/m-p/1599225#M73958</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2025-03-25T21:53:46Z</dc:date>
    </item>
    <item>
      <title>Re: python script tool - need to join csv</title>
      <link>https://community.esri.com/t5/python-questions/python-script-tool-need-to-join-csv/m-p/1599375#M73959</link>
      <description>&lt;P&gt;Yes. I tried tabletotable conversion as well but that caused ERROR 000735 as well.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Mar 2025 11:36:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-tool-need-to-join-csv/m-p/1599375#M73959</guid>
      <dc:creator>Seyed-MahdySadraddini</dc:creator>
      <dc:date>2025-03-26T11:36:20Z</dc:date>
    </item>
    <item>
      <title>Re: python script tool - need to join csv</title>
      <link>https://community.esri.com/t5/python-questions/python-script-tool-need-to-join-csv/m-p/1599380#M73960</link>
      <description>&lt;P&gt;Thanks for walking with me through my problem&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/3265"&gt;@TonyAlmeida&lt;/a&gt;&amp;nbsp;. I figured out the issue was the way I was supplying the csv file into the tool. Please consider this problem resolved!&lt;/P&gt;</description>
      <pubDate>Wed, 26 Mar 2025 12:16:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-tool-need-to-join-csv/m-p/1599380#M73960</guid>
      <dc:creator>Seyed-MahdySadraddini</dc:creator>
      <dc:date>2025-03-26T12:16:28Z</dc:date>
    </item>
  </channel>
</rss>

