Remove comma separator from lines read in from a .csv file
-
I am reading lines from a .csv into a QStringList. Then use a stringlist.split("/n") to put the individual lines into the elements of the stringlist. I settext each stringlist item into a QTextEdit box. The comma is displayed each time. How do I discard this comma so that it is not displayed. I append text where the comma should NOT be.
-
-
@JonB I tried a split on the comma " , " rather than the "\n" and the QTextEdit box ended up going to a scrolled affair with one line in it still with the comma at the end which is not the desired effect. The screen has 40 QTextEdit boxes where this data is to be readily readable. The user should not have to scroll each box to read it.
-
@emp1953
QString &QString::remove(int position, int n) could be used to remove the last character from aQString
, or void QString::chop(int n) does just that. Lots of available methods inQString
. -
This post is deleted!
-
@mchinand This solved my problem. I'm refactoring code that uses data files that were previously generated into Excel Spreadsheets. The user stopped paying for the MSOffice subscription to keep Excel running so now the DAQ equipment is outputting a .csv
I did a hex dump on a couple of files and it appears that the DAQ equipment automatically puts a comma at the end of the line. It's not new equipment so perhaps when it was designed there was some requirement for a .csv line to end with a comma.