You can use this command to replace all commas in the fields of your Species column with spaces:
regexp_replace( "Species", ',', ' ' )
In this post answered by Nathan, the regex_replace
function is described by :
regexp_replace(string,regex,after)
So in your case:
- 'string' is your column (species)
- 'regex' is the character you want changed (comma)
- 'after' is what you want the character to be replaced with (leave empty for a space or add a space between the qutotation marks to create 2 spaces in the result)
EDIT:
I noticed I didn't answer the question completely as it asked how to remove commas in multiple shapefiles. Therefore, if all shapefiles are loaded into QGIS, you can use the following code to iterate through each layer and replace all commas with spaces for a specific field:
field = "Species"
formula = """ replace( "Species", ',', ' ' ) """
for layer in QgsMapLayerRegistry.instance().mapLayers().values():
idx = layer.fieldNameIndex( field )
e = QgsExpression( formula )
e.prepare( layer.pendingFields() )
with edit(layer):
for f in layer.getFeatures():
f[idx] = e.evaluate(f)
layer.updateFeature(f)