File tree 1 file changed +10
-4
lines changed
src/providers/delimitedtext
1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -273,11 +273,11 @@ QgsDelimitedTextProvider::QgsDelimitedTextProvider( QString uri )
273
273
for ( QStringList::iterator it = parts.begin (); it != parts.end (); ++it, ++i )
274
274
{
275
275
// try to convert attribute values to integer and double
276
- if ( couldBeInt[i] )
276
+ if ( couldBeInt[i] && !it-> isEmpty () )
277
277
{
278
278
it->toInt ( &couldBeInt[i] );
279
279
}
280
- if ( couldBeDouble[i] )
280
+ if ( couldBeDouble[i] && !it-> isEmpty () )
281
281
{
282
282
it->toDouble ( &couldBeDouble[i] );
283
283
}
@@ -418,10 +418,16 @@ bool QgsDelimitedTextProvider::nextFeature( QgsFeature& feature )
418
418
switch ( attributeFields[*i].type () )
419
419
{
420
420
case QVariant::Int:
421
- val = QVariant ( tokens[*i].toInt () );
421
+ if ( !tokens[*i].isEmpty () )
422
+ val = QVariant ( tokens[*i].toInt () );
423
+ else
424
+ val = QVariant ( attributeFields[*i].type () );
422
425
break ;
423
426
case QVariant::Double:
424
- val = QVariant ( tokens[*i].toDouble () );
427
+ if ( !tokens[*i].isEmpty () )
428
+ val = QVariant ( tokens[*i].toDouble () );
429
+ else
430
+ val = QVariant ( attributeFields[*i].type () );
425
431
break ;
426
432
default :
427
433
val = QVariant ( tokens[*i] );
You can’t perform that action at this time.
0 commit comments