Skip to main content
Corrected with double quoting the expression
Source Link
Micha
  • 15.8k
  • 23
  • 29

If you prepare your where clause first, it should work (I use f-strings below):

Edited Sorry for the mistake. If you enclose the where clause in double quotes, it should work. (tested here, this time).

  for index, row in df.iterrows():
        city_code = (row['city_ID'])
        expr = f"city_ID=f'"city_ID={city_code}""'
        out = f"out_{city_code}"
        grass.run_command('v.extract', overwrite=True, input='six_cities', output=out, where=expr)

Give this a try, and post back.

If you prepare your where clause first, it should work (I use f-strings below):

  for index, row in df.iterrows():
        city_code = (row['city_ID'])
        expr = f"city_ID={city_code}"
        out = f"out_{city_code}"
        grass.run_command('v.extract', overwrite=True, input='six_cities', output=out, where=expr)

If you prepare your where clause first, it should work (I use f-strings below):

Edited Sorry for the mistake. If you enclose the where clause in double quotes, it should work. (tested here, this time).

  for index, row in df.iterrows():
        city_code = (row['city_ID'])
        expr = f'"city_ID={city_code}"'
        out = f"out_{city_code}"
        grass.run_command('v.extract', overwrite=True, input='six_cities', output=out, where=expr)

Give this a try, and post back.

Source Link
Micha
  • 15.8k
  • 23
  • 29

If you prepare your where clause first, it should work (I use f-strings below):

  for index, row in df.iterrows():
        city_code = (row['city_ID'])
        expr = f"city_ID={city_code}"
        out = f"out_{city_code}"
        grass.run_command('v.extract', overwrite=True, input='six_cities', output=out, where=expr)