Select to view content in your preferred language

How to use a variable with the function calculate () with ArcGIS API for Python

742
2
Jump to solution
10-31-2018 10:36 PM
explocarto
Regular Contributor

calculate(where, calc_expression, sql_format='standard')

lst_country = ["country1","country2","country3"]

for country in lst lst_country:

      update_result = commune_flayer.calculate(where="nom = country", calc_expression={"field": "date_horaire", "value": provinces.attributes['date_horaire']})

Thanks

0 Kudos
1 Solution

Accepted Solutions
explocarto
Regular Contributor
'nom = "{}"'.format(country)

It's good I finally found. It was necessary to declare this syntax

"nom = '{}'".format(country)

Thank you

View solution in original post

0 Kudos
2 Replies
Luke_Pinner
MVP Regular Contributor
'nom = "%s"' % country
# or
'nom = "{}"'.format(country)

Look up Python string formatting.  Don't forget you need quotes around string values in where clauses.

explocarto
Regular Contributor
'nom = "{}"'.format(country)

It's good I finally found. It was necessary to declare this syntax

"nom = '{}'".format(country)

Thank you

0 Kudos