Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extra linefeed #16

Closed
ritskes opened this issue May 9, 2016 · 2 comments
Closed

extra linefeed #16

ritskes opened this issue May 9, 2016 · 2 comments

Comments

@ritskes
Copy link

ritskes commented May 9, 2016

We have different results in notepad, notepad++ and wps
image

Actually we just took an original CSV and removed some fields and wrote it back using your CSV program. But the original file looks way different then the CSV made by your LIB.
Looks like there is an extra linefeed.

What we did is:

void MainWindow::on_PB_Start_clicked()
{

QString dir;
if(ui->spinBoxProvider->value()==1)
{
    dir = "C:/Users/Ritsk/Documents/QT PROJECTS/TarievenProgramma/CSV/DIDLOGIC";
}
else
{
    dir = "C:/Users/Ritsk/Documents/QT PROJECTS/TarievenProgramma/CSV/COMMPEAK";
}

QDir directory(dir);
const QString FS = QFileDialog::getOpenFileName(this,tr("Open File"), directory.absolutePath(), tr("Files (*.csv)"));
QList<QStringList> data = QtCSV::Reader::readToList(FS);
data.removeAt(0);
for(int i=1;i<data.size();i++)
{
    if(ui->spinBoxProvider->value()==1)
    {
        data[i].removeAt(0);
    }
    else
    {
        data[i].removeAt(0);
        data[i].removeAt(2);
    }
}
QtCSV::StringData strData;
QStringList Header;
Header << "RATE" << "PREFIX";
strData.addRow(Header);
for(int i=1;i<data.size();i++)
{
    QStringList strList;
    if(ui->spinBoxProvider->value()==1)
    {
        strList << data[i].at(0) << data[i].at(1);
    }
    else
    {
        //QString s = data[i].at(0);
        //s + "\r";
        strList << data[i].at(1) << data[i].at(0);
    }
    strData.addRow(strList);
}

bool writeResult;
if(ui->spinBoxProvider->value()==1)
{
    writeResult = QtCSV::Writer::write("C:/Users/Ritsk/Documents/QT PROJECTS/TarievenProgramma/DIDLOGIC.csv", strData);

}
else
{
    writeResult = QtCSV::Writer::write("C:/Users/Ritsk/Documents/QT PROJECTS/TarievenProgramma/COMMPEAK.csv", strData);
}

if(writeResult)
{
    QMessageBox msgBox;
    msgBox.setText("CSV has been CONVERTED");
    msgBox.exec();
}
else
{
    QMessageBox msgBox;
    msgBox.setText("ERROR: CSV has NOT been CONVERTED!!");
    msgBox.exec();
}

I have send the code to your email adres as well.

WHAT are we doing WRONG?
Why is the original different then the one made with your LIB?

@iamantony
Copy link
Owner

iamantony commented May 10, 2016

Quite interesting. It seems that problem is really in a extra line feed. Thanks for your original files. I'll try to figure out what the problem is.

@iamantony
Copy link
Owner

Bug is fixed: 7c34e32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants