Skip to content
Permalink
Browse files

Merge pull request #2237 from ccrook/csv_field_name_fix

Removing unnecessary restriction on CSV provider field names
  • Loading branch information
ccrook committed Aug 6, 2015
2 parents c4ea8de + dc2de77 commit 118eea5ada437558361251422ac3d9bcfe99beb9
@@ -52,7 +52,6 @@ QgsDelimitedTextFile::QgsDelimitedTextFile( QString url ) :
mMaxRecordNumber( -1 ),
mMaxFieldCount( 0 ),
mDefaultFieldName( "field_%1" ),
mInvalidFieldRegexp( "^\\d*(\\.\\d*)?$" ),
// field_ is optional in following regexp to simplify QgsDelimitedTextFile::fieldNumber()
mDefaultFieldRegexp( "^(?:field_)?(\\d+)$", Qt::CaseInsensitive )
{
@@ -429,8 +428,8 @@ void QgsDelimitedTextFile::setFieldNames( const QStringList &names )
name = name.trimmed();
if ( name.length() > mMaxNameLength ) name = name.mid( 0, mMaxNameLength );

// If the name is invalid then reset it to default name
if ( mInvalidFieldRegexp.exactMatch( name ) )
// If the name is empty then reset it to default name
if ( name.length() == 0 )
{
name = mDefaultFieldName.arg( fieldNo );
}
@@ -381,7 +381,6 @@ class QgsDelimitedTextFile : public QObject
int mMaxFieldCount;

QString mDefaultFieldName;
QRegExp mInvalidFieldRegexp;
QRegExp mDefaultFieldRegexp;
};

@@ -74,8 +74,8 @@ def test_003_field_naming():
'data': u'Some data',
'field_4': u'Some info',
'data_2': u'NULL',
'field_6': u'NULL',
'field_7': u'NULL',
'28_1': u'NULL',
'24.5': u'NULL',
'field_3_1': u'NULL',
'data_1': u'NULL',
'field_10': u'NULL',
@@ -100,8 +100,8 @@ def test_004_max_fields():
'data': u'Some data',
'field_4': u'Some info',
'data_1': u'NULL',
'field_6': u'NULL',
'field_7': u'NULL',
'28_1': u'NULL',
'24.5': u'NULL',
'#fid': 2L,
'#geometry': 'None',
},

0 comments on commit 118eea5

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