[QGIS Commit] r13621 - trunk/qgis/src/providers/delimitedtext

svn_qgis at osgeo.org svn_qgis at osgeo.org
Tue Jun 1 17:39:38 EDT 2010


Author: jef
Date: 2010-06-01 17:39:36 -0400 (Tue, 01 Jun 2010)
New Revision: 13621

Modified:
   trunk/qgis/src/providers/delimitedtext/qgsdelimitedtextprovider.cpp
Log:
[FEATURE] delimited text provider: allow empty values in numeric columns

Modified: trunk/qgis/src/providers/delimitedtext/qgsdelimitedtextprovider.cpp
===================================================================
--- trunk/qgis/src/providers/delimitedtext/qgsdelimitedtextprovider.cpp	2010-06-01 21:16:01 UTC (rev 13620)
+++ trunk/qgis/src/providers/delimitedtext/qgsdelimitedtextprovider.cpp	2010-06-01 21:39:36 UTC (rev 13621)
@@ -273,11 +273,11 @@
       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 @@
       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] );



More information about the QGIS-commit mailing list