Hi -
I'm trying to join a csv file to a shapefile using arcpy. I have ArcGIS Pro v2.8. Problem is, the join fields have leading zeros. The field in the shapefile has the correct type (text) but the field in the csv imports as integer.
Here is my code:
import arcpy
arcpy.env.workspace = "myPath"
spatial_import = "pathToShapeFile"
tab_inport = "pathToCSV"
LAYER = arcpy.management.JoinFields(in_data=spatial_import, in_field='county',join_table='tab_import', join_field="county")
For counties with a "100" code series the join works but not for counties with leading zeros.
I've tried importing the csv file into Pandas as a dataframe (formatting the "county" field as a string) and then redoing the join but arcpy threw an error (apparently you can't use a Pandas dataframe in JoinFields).
I have a lot of maps with joins like this so I was trying to streamline the workload. Any ideas about how to import the csv as a table while preserving leading zeros so the join will work?
Or, manipulating data using Pandas and then joining with a shapefile?
Thanks.