QPyNullVariant when working with csv

المشرف العام

Administrator
طاقم الإدارة
id = 5 expr = QgsExpression("ID ="+str(id)) selected = csv_layer.getFeatures(QgsFeaturesRequest(expr)) features_list = [feature.attributes() for feature in selected] print feature_listIf I run this code, where csv_layer is valid delimited text layer, it prints list, that is correct.

But then I want to show it in tableWidget. I wrote function, that works, if I pass it data, that I received from vector layer. But if I pass it data from csv_layer, it only prints all String values, and Real and Integer shows as QPyNullVariant. In attribute table all values are correct and of correct type.

I tried even .csvt file, but it only shows those values, that I set to String.I could set all of those values to String, but than in attribute table sorting won't work properly (13 goes before 2).

Is there a solution that I am missing, or should I stick with setting all of them to string?



أكثر...
 
أعلى