A naïve approach would be:
- Open input file and output file: QFile::open()
- Read a line from the input file: QFile::readLine() or QTextStream::readLine()
- Split the line on the comma character: QString::split()
- Check the fields and if the line is to be kept write it to the output file: QFile::write() or QTextStream operator <<
- Repeat from 2 until input file exhausted
- Close files
- On successful completion replace input file with output file
However, "CSV File" covers a multitude of slightly different formats: quotes, no quotes, embedded commas, embedded new lines etc. More complex handling is required for many of these scenarios.
Bookmarks