Skip to content

Commit 2431118

Browse files
author
jef
committed
[FEATURE] delimited text provider: allow empty values in numeric columns
git-svn-id: http://svn.osgeo.org/qgis/trunk@13621 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 0d8940d commit 2431118

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/providers/delimitedtext/qgsdelimitedtextprovider.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,11 +273,11 @@ QgsDelimitedTextProvider::QgsDelimitedTextProvider( QString uri )
273273
for ( QStringList::iterator it = parts.begin(); it != parts.end(); ++it, ++i )
274274
{
275275
// try to convert attribute values to integer and double
276-
if ( couldBeInt[i] )
276+
if ( couldBeInt[i] && !it->isEmpty() )
277277
{
278278
it->toInt( &couldBeInt[i] );
279279
}
280-
if ( couldBeDouble[i] )
280+
if ( couldBeDouble[i] && !it->isEmpty() )
281281
{
282282
it->toDouble( &couldBeDouble[i] );
283283
}
@@ -418,10 +418,16 @@ bool QgsDelimitedTextProvider::nextFeature( QgsFeature& feature )
418418
switch ( attributeFields[*i].type() )
419419
{
420420
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() );
422425
break;
423426
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() );
425431
break;
426432
default:
427433
val = QVariant( tokens[*i] );

0 commit comments

Comments
 (0)