Skip to content
Permalink
Browse files

Fixed #3818

  • Loading branch information
wonder-sk authored and timlinux committed May 15, 2011
1 parent 716742b commit 3eb0d667c7f35d7eb1fce0d661d9e20e4fc96510
Showing with 12 additions and 8 deletions.
  1. +12 −8 src/providers/delimitedtext/qgsdelimitedtextprovider.cpp
@@ -69,15 +69,15 @@ QString QgsDelimitedTextProvider::readLine( QTextStream *stream )

QStringList QgsDelimitedTextProvider::splitLine( QString line )
{
QgsDebugMsg( "Attempting to split the input line: " + line + " using delimiter " + mDelimiter );
QgsDebugMsgLevel( "Attempting to split the input line: " + line + " using delimiter " + mDelimiter, 3 );

QStringList parts;
if ( mDelimiterType == "regexp" )
parts = line.split( mDelimiterRegexp );
else
parts = line.split( mDelimiter );

QgsDebugMsg( "Split line into " + QString::number( parts.size() ) + " parts" );
QgsDebugMsgLevel( "Split line into " + QString::number( parts.size() ) + " parts", 3 );

if ( mDelimiterType == "plain" )
{
@@ -454,7 +454,7 @@ bool QgsDelimitedTextProvider::nextFeature( QgsFeature& feature )
QString line = readLine( mStream ); // Default local 8 bit encoding
if ( line.isEmpty() )
continue;

// lex the tokens from the current data line
QStringList tokens = splitLine( line );

@@ -528,27 +528,31 @@ bool QgsDelimitedTextProvider::nextFeature( QgsFeature& feature )
i != mAttributesToFetch.end();
++i )
{
QString &value = tokens[attributeColumns[*i]];
int fieldIdx = *i;
if ( fieldIdx < 0 || fieldIdx >= attributeColumns.count() )
continue; // ignore non-existant fields

QString &value = tokens[attributeColumns[fieldIdx]];
QVariant val;
switch ( attributeFields[*i].type() )
switch ( attributeFields[fieldIdx].type() )
{
case QVariant::Int:
if ( !value.isEmpty() )
val = QVariant( value );
else
val = QVariant( attributeFields[*i].type() );
val = QVariant( attributeFields[fieldIdx].type() );
break;
case QVariant::Double:
if ( !value.isEmpty() )
val = QVariant( value.toDouble() );
else
val = QVariant( attributeFields[*i].type() );
val = QVariant( attributeFields[fieldIdx].type() );
break;
default:
val = QVariant( value );
break;
}
feature.addAttribute( *i, val );
feature.addAttribute( fieldIdx, val );
}

// We have a good line, so return

0 comments on commit 3eb0d66

Please sign in to comment.
You can’t perform that action at this time.