3

I have 190 layers in shape file with attribute filled in lower case. I want to change data of all tables in uppercase using Qgis.

I am able do to do it one by one using upper in expression.

How to do for all layers in one go?

closed as off-topic by ahmadhanb, Jochen Schwarze, Fran Raga, LaughU, xunilk May 20 at 13:08

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "When seeking help to debug/write/improve code always provide the desired behavior, a specific problem/error and the shortest code (as formatted text, not pictures) needed to reproduce it in the question body. Providing a clear problem statement and a code attempt helps others to help you." – ahmadhanb, Jochen Schwarze, Fran Raga, LaughU, xunilk
If this question can be reworded to fit the rules in the help center, please edit the question.

3

You need to use pyqgis to loop over all the field names to change their case to uppercase.

The following snippet can be used to change all field names in one shapefile into uppercase

uri = r"F:\Ahmad\Test\PT\Cities.shp"
vlayer = iface.addVectorLayer(uri, "cities", "ogr")
for field in vlayer.fields():
    name = field.name()
    with edit(vlayer):
        idx = vlayer.fields().indexFromName(name)
        vlayer.renameAttribute(idx, name.upper())

del vlayer

Before:

enter image description here

After running the code:

enter image description here

The above code was used inside QGIS 3.4.5 with pyqgis 3. If you want to loop over the 190 shapefile, you need to use os.walk().

Not the answer you're looking for? Browse other questions tagged or ask your own question.