So, I have a .csv file.
Here an example how the a row from the original .csv looks like:
"AREA",44.37,-00.83,"5","1","8","E","E",,,"KKI","KKO"
Some lines have missing latitudes and longitudes, so I want to get rid of them. Should be easy. Thats my snippet (Python 2.7) that does it:
import csv
n = 0
m = 0
nf = open("newfilefile.csv", "w")
with open("oldfile.csv", "r") as csvFile:
originalData = csv.reader(csvFile, delimiter=",")
for lines in originalData:
if len(lines[9]) < 1:
n += 1
print 'Missing Latitude', n
elif len(lines[10]) < 1:
m += 1
print 'Missing Longitude', m
else:
nf.write(str(lines[0]).strip() + "," + str(lines[1]).strip() + "," + str(lines[2]).strip() + "," + str(lines[3]).strip() + "," + str(lines[4]).strip() + "," + str(lines[5]).strip() ... + "\n" )
nf.close()
Thats how the same row would look like in my new .csv:
AREA,44.37,-00.83,5,1,8,E,E,,,KKI,KKO
Beforehand I could open the original csv file. QGis just said that there are missing geometry information. Now I get a bunch of errors, namely:
Invalid record format at line 324
and so forth... I compared the lines where it marks the error and the only difference is that in the oldfile, everything is wrapped in " while in the file my script creates that is not the case.
Why does QGis need " around every from a column (if that is the mistake) and how would I add that to my snippet?

"but only columns which contain strings."5"is a string but5is a number -> schema mismatch -> failure. – user30184 Apr 15 '15 at 08:07"since I convert everything into a string... – four-eyes Apr 15 '15 at 08:27