Fix for delimited text files having a delimiter at end of each line

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@2337 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
gsherman 2004-11-26 18:19:26 +00:00
parent 4adfaaa909
commit 58c2d45251
2 changed files with 16 additions and 5 deletions

View File

@ -83,7 +83,7 @@ void QgsDelimitedTextPluginGui::updateFieldLists()
" using delimiter " << txtDelimiter->text() << std::endl;
#endif
QStringList fieldList = QStringList::split(QRegExp(txtDelimiter->text()), line, true);
QStringList fieldList = QStringList::split(QRegExp(txtDelimiter->text()), line);
#ifdef QGISDEBUG
std::cerr << "Split line into " << fieldList.size() << " parts" << std::endl;
@ -94,8 +94,11 @@ void QgsDelimitedTextPluginGui::updateFieldLists()
int fieldPos = 0;
for ( QStringList::Iterator it = fieldList.begin(); it != fieldList.end(); ++it ) {
// add item to both drop-downs (X field and Y field)
if((*it).length() > 0)
{
cmbXField->insertItem(*it);
cmbYField->insertItem(*it);
}
}
// close the file
file->close();

View File

@ -1,9 +1,9 @@
/***************************************************************************
qgsdelimitedtextprovider.cpp - Data provider for delimted text
-------------------
begin : 2004-02-27
copyright : (C) 2004 by Gary E.Sherman
email : sherman at mrcc.com
begin : 2004-02-27
copyright : (C) 2004 by Gary E.Sherman
email : sherman at mrcc.com
***************************************************************************/
/***************************************************************************
@ -98,7 +98,11 @@ email : sherman at mrcc.com
// We don't know anything about a text based field other
// than its name. All fields are assumed to be text
int fieldPos = 0;
for ( QStringList::Iterator it = fieldList.begin(); it != fieldList.end(); ++it ) {
for ( QStringList::Iterator it = fieldList.begin(); it != fieldList.end(); ++it )
{
QString field = *it;
if(field.length() > 0)
{
attributeFields.push_back(QgsField(*it, "Text"));
fieldPositions[*it] = fieldPos++;
// check to see if this field matches either the x or y field
@ -120,7 +124,11 @@ email : sherman at mrcc.com
std::cerr << "Adding field: " << *it << std::endl;
#endif
}
}
#ifdef QGISDEBUG
std::cerr << "Field count for the delimited text file is " << attributeFields.size() << std::endl;
#endif
}else
{
// examine the x,y and update extents