Using the MMQGIS plugin in QGIS I can't join my CSV file...

This is what QGIS returns me:

An error has occurred while executing Python code:

Traceback (most recent call last): File "/home/elisabet/.qgis/python/plugins/mmqgis/mmqgis_dialogs.py", line 217, in run joinattribute, outfilename, notfoundname, 1) File "/home/elisabet/.qgis/python/plugins/mmqgis/mmqgis_library.py", line 516, in mmqgis_attribute_join if duplication[0] != '_': IndexError: string index out of range

Python version: 2.7.5+ (default, Sep 19 2013, 13:52:09) [GCC 4.8.1]

QGIS version: 1.7.5-Wroclaw Wroclaw, exported

Python path: ['/usr/share/qgis/python', '/home/elisabet/.qgis/python', '/home/elisabet/.qgis/python/plugins', '/usr/share/qgis/python/plugins', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PILcompat', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/python2.7/dist-packages/ubuntu-sso-client', '/usr/lib/python2.7/dist-packages/ubuntuone-client', '/usr/lib/python2.7/dist-packages/ubuntuone-control-panel', '/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol', '/home/elisabet/.qgis/python/plugins/mmqgis/forms', '/usr/share/qgis/python/plugins/fTools/tools']

2 Answers 2


I can't give you an exact answer, but I can explain what your "String index out of range" means.

That error message is typical of an error generated when a segment of the program code is expecting more entries in an array than it has available.

However, realizing that not everyone here is a professional software developer, lets try and describe this in a non software developer way :-)

First - What are arrays

An array is like a list of numbered boxes, and each box can hold a certain item of data, so if you had an array of numbers, you might have something like the following


You can put things into the box by saying

box[0] = 50 or box[5] = 10

or if your array is an array of strings for example:

box[0] = "Word" or box[3] = "town name"

Taking the example above, you have boxes numbered from 0 to 5, meaning you have 6 boxes in total.

If you tried to access box[7] then you'd get an error similar to the one your seeing, it's the program code's way of saying, I don't have a box to use at index 7.

Second - Likely causes

OK, so now you have an idea as to why your seeing the error, there are 2 things that spring to mind as to what might be causing it for you.

1) Since your loading in a CSV file, there's a very good chance your CSV file is either corrupt, or has some bad formatting in


imagine you have a CSV file that looks like the following

1, "Town 1", -1.2345, 54.5678, 20000, "House 10"
2, "Town 2", -1.2345, 54.5678, 20000, "House 11"
3, "Town 3", -1.2345, 54.5678, 20000, "House 12"
4, "Town 4", -1.2345, 54.5678, 20000, "House 13"
5, "Town 5", -1.2345, 54.5678, 20000, "House 14"
6, "Town 6", -1.2345, 54.5678, 20000, "House 15"

if you imagine that each comma separates up a box in an array, then you can start to imagine that your CSV file actually looks like this to the computer

line1[0] = 1, line1[1] = "Town 1", line1[2] = -1.2345, line1[3] = 54.5678, line1[4] = 20000, line1[5] = "House 10"

and for each line going down the list, you might have line1[], line2[], line3[] and so on.

Now imagine that your CSV file is a bit corrupt, for example, the 3rd line now looks like this

3, "Town 3", -1.2345, 54.567

because it has something missing from the line.

Up to this point, the program code reading your CSV file, knows that every line it's read from the file has had 6 boxes in it (0 to 5), then all of a sudden it now reads a line that only has 4 (0 to 3) boxes in it.

So where it expects to find the remaining boxes with other info in, when it tries to read them, an error is generated, and that error is an index not present or out of range related error.

Another possible and similar cause is that the CSV file is not actually corrupted, but has confusing information.

Since CSV files use commas to separate the boxes, then a misplaced comma might cause it to think there is an incorrect number of boxes, for example:

1, "Town 1", -1.2345, 54.5678, 20000, "House 10 street 2"
2, "Town 2", -1.2345, 54.5678, 20000, "House 11, street 1"

Might cause the CSV reading code to think that line 2 has 1 more box available than line 1.

2) The second problem you might be encountering is in the length of a string.

Strings are just a special type of array, where each array represents a single letter, if the program code is expecting for example:

"A town"

but gets


IE nothing, then that error could be presented. This is however only to be expected if your trying to split up specific information yourself from a string, and is very rare.

  • 1
    Thank you for your answer, it was very didactic. thanks a lot for your time.
    – elisabet
    Jan 21, 2014 at 11:07

I don't know about the error (String index out of range) but I do advice you to upgrade your QGIS version (from 1.7.5 to 2.0).

To do this, you must add a new repository. Instructions are located here: http://www.qgis.org/en/site/forusers/alldownloads.html#ubuntu

  • I fixed downloading again Python and installing the new version of QGIS. Thanks
    – elisabet
    Jan 21, 2014 at 11:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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