Python ogr filter attribute SQL

المشرف العام

Administrator
طاقم الإدارة
I have a shapefile with 4 attribute fields (MC_ID, MC_info, C_ID, C_info).

I want to change some MC_ID values selecting the features by C_info.

For example: I want to set MC_ID = 2 for C_info = g19, C_info = g22 and C_info = g23.

The problem is that I am not succeeding in filtering the shapefile.If I set

mylayer.SetAttributeFilter("C_info = 'g19'" or "C_info = 'g22'" or "C_info = 'g23'")it filters only one feature (the first one).

I also tried to use the command ExecuteSQL

result = dataSource.ExecuteSQL("select * from roi_classMacro WHERE C_info = 'g19'" or "C_info = 'g22'" or "C_info = 'g23')and also

result = dataSource.ExecuteSQL("select * from roi_classMacro WHERE (C_info = 'g19') or (C_info = 'g22')")but it returns me NoneType (in the second case QGIS crashes).

Where am I wrong?

Thanks in advance



أكثر...
 
أعلى