Skip to content

Commit

Permalink
Fixed #3818
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk authored and timlinux committed May 15, 2011
1 parent 716742b commit 3eb0d66
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/providers/delimitedtext/qgsdelimitedtextprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" )
{
Expand Down Expand Up @@ -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 );

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3eb0d66

Please sign in to comment.