Skip to content
Permalink
Browse files

Removing unnecessary restriction on field names

  • Loading branch information
ccrook committed Aug 6, 2015
1 parent c4ea8de commit dc2de774c226855a4a78f2dffb46188d94a03b35
@@ -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 dc2de77

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