Skip to content
Permalink
Browse files
[FEATURE] delimited text provider: allow empty values in numeric columns
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13621 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Jun 1, 2010
1 parent 4a0cfab commit 32d4c519ca3a6f67705201b599c4d63399d0f039
Showing with 10 additions and 4 deletions.
  1. +10 −4 src/providers/delimitedtext/qgsdelimitedtextprovider.cpp
@@ -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] );
}
@@ -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] );

0 comments on commit 32d4c51

Please sign in to comment.