Hello i am currently running into an issue where i am trying to get a value from a table created from summary statistics into my calculate field expression.
Based on what is in the table i wish to take the MAX_DATECREATED value and assign it to Last_Update_Date field in my python script.
How would i go about achieving pulling thr value located in the table and assigning it specifcally to my calculate field expression?
To give addtional context, the model section of calculate field i am trying to convert into this,
Based on the model, how would i take the value found in my Attribute table from summary statistics and assign to last_update_date the exact value found?
my code is as follows
# Summary Statistics
#Specify output variable
BuildCablesMax = 'Build_Cable_MaxDateCreated'
#Calculate summary statistics for fields
arcpy.analysis.Statistics(BuildCableLines, BuildCablesMax, [['DATECREATED', "MAX"]])
#Calculate Field 7
arcpy.management.CalculateField(BuildCableLines, "Last_Update_Date", "Last_Update_Date" == )
for the expression i want to assign the value from my BuildCablesMax on MAX_DATECREATED column to my BuildCableLines on Last_Update_Date column equaling this exact value.
Solved! Go to Solution.
Your post and screenshots are a little confusing. Do you have only one row in the summary table?
If so, you can do it like this:
max_date = [row[0] for row in arcpy.da.SearchCursor(BuildCablesMax, ["MAX_DATECREATED"])][0]
arcpy.management.CalculateField(BuildCableLines, "Last_Update_Date", f"'{max_date}'")
If your summary table has multiple rows, you should probably use Join Field.
Your post and screenshots are a little confusing. Do you have only one row in the summary table?
If so, you can do it like this:
max_date = [row[0] for row in arcpy.da.SearchCursor(BuildCablesMax, ["MAX_DATECREATED"])][0]
arcpy.management.CalculateField(BuildCableLines, "Last_Update_Date", f"'{max_date}'")
If your summary table has multiple rows, you should probably use Join Field.
Hello,
I can confirm this table only has one row in it,
This has now giving me the last_update_date as the same date located in the MAX_DATECREATED column of my table.
Thank you so much.
Have a lovely day!
Madam