how i can identify and read the columns of a csv file ?
-
@Pl45m4 @KroMignon yes I have checked I have the right values now I have a graph but it is not the same that I do with the csv file, I cannot find the same graph, what do you think please ?
-
@julie546 said in how i can identify and read the columns of a csv file ?:
but it is not the same that I do with the csv file,
What do you mean with not the same?
@KroMignon this is what I found with qt
and this is what I have to find
despite I made qDebug () << x;
qDebug () << y;
and I found the same values with csv file -
@KroMignon this is what I found with qt
and this is what I have to find
despite I made qDebug () << x;
qDebug () << y;
and I found the same values with csv file -
@julie546
Hi
If you look closely they are the same.
Its just you are using QLineSeries which draws lines between the points so
that why it looks differernt.Maybe the scatter type can be used
https://doc.qt.io/qt-5/qtcharts-scatterchart-example.htmlinstead of the LineSeries.
-
@julie546
Hi
If you look closely they are the same.
Its just you are using QLineSeries which draws lines between the points so
that why it looks differernt.Maybe the scatter type can be used
https://doc.qt.io/qt-5/qtcharts-scatterchart-example.htmlinstead of the LineSeries.
-
@mrjj
thank you for your reply I have changed it but there are some missing points
QScatterSeries * series = new QScatterSeries;
series->setMarkerShape(QScatterSeries::MarkerShapeRectangle); -
@julie546
Well it does look more like it
so the question if those points go missing during reading or where they go.What does the draw correct looking diagram ?
I mean what app ? -
@mrjj it is a 'lidar tg15' sensor
i did series->append(x, y);
qDebug() << y;
qDebug() << x;
and I found all the points -
@julie546
Ok but the right diagram you showed the picture of.
Did you hand draw this or did an app do it?since no points is missing im simply wondering if that data would allow the correct diagram at all.
-
@julie546
ok. and you used the same CSV file there ?and you compared the values we insert, value by value to make sure it reads as it should ?
I mean if it could not convert for some reason it would silently continue.
if(!ok) continue;
some of the points to the far right seems more out there than on correct diagram.
should be around 6.0 but is 6.8 -
@julie546
ok. and you used the same CSV file there ?and you compared the values we insert, value by value to make sure it reads as it should ?
I mean if it could not convert for some reason it would silently continue.
if(!ok) continue;
some of the points to the far right seems more out there than on correct diagram.
should be around 6.0 but is 6.8 -
-
@JonB said in how i can identify and read the columns of a csv file ?:
As @mrjj said, just to humour us, in the two places you have
if(!ok)
continue;please put in above the if
Q_ASSERT(ok);The reason why there is continue, is because the CSV file contains the column headers, which are strings and cannot be converted to float.
WithQ_ASSERT()
the program will be interrupted. -
@JonB said in how i can identify and read the columns of a csv file ?:
As @mrjj said, just to humour us, in the two places you have
if(!ok)
continue;please put in above the if
Q_ASSERT(ok);The reason why there is continue, is because the CSV file contains the column headers, which are strings and cannot be converted to float.
WithQ_ASSERT()
the program will be interrupted.@KroMignon
ah so it should skip first col. always. good catch.
Im just wondering if all points really get converted as
else i dont see how the graphs can be that differnt. -
@JonB said in how i can identify and read the columns of a csv file ?:
As @mrjj said, just to humour us, in the two places you have
if(!ok)
continue;please put in above the if
Q_ASSERT(ok);The reason why there is continue, is because the CSV file contains the column headers, which are strings and cannot be converted to float.
WithQ_ASSERT()
the program will be interrupted.@KroMignon said in how i can identify and read the columns of a csv file ?:
The reason why there is continue, is because the CSV file contains the column header
Surely that's for the first line only?
-
@KroMignon said in how i can identify and read the columns of a csv file ?:
The reason why there is continue, is because the CSV file contains the column header
Surely that's for the first line only?
-
@JonB @mrjj @KroMignon
I remove the headers and I replace
if (! ok)
continue;
by Q_ASSERT (ok);
but it's the same result@julie546 said in how i can identify and read the columns of a csv file ?:
I remove the headers and I replace
if (! ok)
continue;
by Q_ASSERT (ok);
but it's the same resultI suppose it is a simple precision issue, you should replace
toFloat()
withtoDouble()
:while (!filelidar.atEnd()) { QString line = filelidar.readLine(); const auto parts = line.split (','); if(parts.size() >= 2) { bool ok; qreal x = parts.at(0).toDouble(&ok); if(!ok) { qDebug() << "Could not parse X value" << parts.at(0); continue; } qreal y = parts.at(1).toDouble(&ok); if(!ok) { qDebug() << "Could not parse Y value" << parts.at(1); continue; } series->append(x, y); } }
-
@julie546 said in how i can identify and read the columns of a csv file ?:
I remove the headers and I replace
if (! ok)
continue;
by Q_ASSERT (ok);
but it's the same resultI suppose it is a simple precision issue, you should replace
toFloat()
withtoDouble()
:while (!filelidar.atEnd()) { QString line = filelidar.readLine(); const auto parts = line.split (','); if(parts.size() >= 2) { bool ok; qreal x = parts.at(0).toDouble(&ok); if(!ok) { qDebug() << "Could not parse X value" << parts.at(0); continue; } qreal y = parts.at(1).toDouble(&ok); if(!ok) { qDebug() << "Could not parse Y value" << parts.at(1); continue; } series->append(x, y); } }
@KroMignon thank you for your answer you helped me a lot,I tried it but it's the same thing, you don't think it's about this instruction ?
QScatterSeries * series = new QScatterSeries;
series->setMarkerShape(QScatterSeries::MarkerShapeRectangle); -
@mrjj
thank you for your reply I have changed it but there are some missing points
QScatterSeries * series = new QScatterSeries;
series->setMarkerShape(QScatterSeries::MarkerShapeRectangle);@julie546 said in how i can identify and read the columns of a csv file ?:
thank you for your reply I have changed it but there are some missing points
I am not sure that these points are actually missing. As far as I can tell you draw the points as blue squares with a white border (on a white background). If you look closely a lot of points are almost vanishing in the drawing (and some will vanish altogether). This is because the points are to close together (and some unfortunate pattern in your data) that the points overlap excactly so that you only see the white border of neighboring points (actually you don't see them as they are white on white). This makes it seem as if the points are missing.
Try changing either the background color or the color of the borders of the data points. Or remove the border to be comparable to Excel (if that is what you want). I can't help you with the right functions as I have never used these charts.
-
@KroMignon thank you for your answer you helped me a lot,I tried it but it's the same thing, you don't think it's about this instruction ?
QScatterSeries * series = new QScatterSeries;
series->setMarkerShape(QScatterSeries::MarkerShapeRectangle);@julie546 said in how i can identify and read the columns of a csv file ?:
series->setMarkerShape(QScatterSeries::MarkerShapeRectangle);
This will only change the way the point is draw (https://doc.qt.io/qt-5/qscatterseries.html#markerShape-prop).
I don't think this will change anything.Are you sure you have exported all points in your CSV file?
For me, it looks like positions are missed.