Skip to content

Commit

Permalink
[FEATURE] delimited text provider: allow empty values in numeric columns
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@13621 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Jun 1, 2010
1 parent 0d8940d commit 2431118
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/providers/delimitedtext/qgsdelimitedtextprovider.cpp
Expand Up @@ -273,11 +273,11 @@ QgsDelimitedTextProvider::QgsDelimitedTextProvider( QString uri )
for ( QStringList::iterator it = parts.begin(); it != parts.end(); ++it, ++i )
{
// try to convert attribute values to integer and double
if ( couldBeInt[i] )
if ( couldBeInt[i] && !it->isEmpty() )
{
it->toInt( &couldBeInt[i] );
}
if ( couldBeDouble[i] )
if ( couldBeDouble[i] && !it->isEmpty() )
{
it->toDouble( &couldBeDouble[i] );
}
Expand Down Expand Up @@ -418,10 +418,16 @@ bool QgsDelimitedTextProvider::nextFeature( QgsFeature& feature )
switch ( attributeFields[*i].type() )
{
case QVariant::Int:
val = QVariant( tokens[*i].toInt() );
if( !tokens[*i].isEmpty() )
val = QVariant( tokens[*i].toInt() );
else
val = QVariant( attributeFields[*i].type() );
break;
case QVariant::Double:
val = QVariant( tokens[*i].toDouble() );
if( !tokens[*i].isEmpty() )
val = QVariant( tokens[*i].toDouble() );
else
val = QVariant( attributeFields[*i].type() );
break;
default:
val = QVariant( tokens[*i] );
Expand Down

0 comments on commit 2431118

Please sign in to comment.