[Kst] Problem with CSV files

Peter Kümmel syntheticpp at gmx.net
Fri Nov 1 08:12:20 UTC 2013


On 01.11.2013 03:29, Syam wrote:
> On 01-Nov-2013 3:31 AM, "Alexander Semke" <Alexander.Semke at web.de> wrote:
>>
>> Hi,
>>
>>> How could we change it, so it also detects empty columns?
>> In labplot2 we use QString::split with QString::SkipEmptyParts to split
> each
>> line we read into its parts. By doing so with this file, we end up with
> two
>> valid columns.
>
> I've gone through the code for tracking this issue. So far, I think Kst
> uses SkipEmptyParts while identifying columns so that only two columns are
> listed. But while reading data from each line, it uses a different method
> than QString::split. It scans for the separator character and converts each
> token to a double value. Here, the initial comma causes a problem as the
> code doesn't skip blank fields.
>
> I think we should have the same logic for recognising columns and while
> reading data. What if we use KeepEmptyParts while scanning for columns? I
> believe things will then work fine even if lines have missing fields.
>


Seems it is a corner case of this bug:

     https://bugs.kde.org/show_bug.cgi?id=301203

so we don't have to change the column-detection code ;)

The bug was fixed by this:

     https://github.com/Kst-plot/kst/commit/97e4ea9002300aa0661e6dfc6ab0b631d64fefe2

I pushed a patch, which removes the assumption, that the row always starts with a number.
Please check if it works for you now.

Thanks,
Peter





More information about the Kst mailing list