#1221 Column selection by name not well documented

closed-fixed
nobody
None
5
2015-03-23
2013-03-06
Erik
No

Selection of columns by name returns the wrong column if the first part of the search string matches. From ticket #539:

"The current version returns the first column providing a matching leading substring. That is, column("A") would match a column labeled "Age". This is convenient but might be a bad idea, since column("Site 1") might unexpectedly return a column labeled "Site 17" if it occurred before any column labeled "Site 1" exactly."

This should at least be documented but, much better, the whole string should be found.

Discussion

  • Ethan Merritt

    Ethan Merritt - 2013-03-14

    Ticket moved from /p/gnuplot/patches/614/

     
  • Ethan Merritt

    Ethan Merritt - 2013-03-14

    It is more complicated than that, but yes 4.6 and 4.7 are both broken in different ways with regard to specifying only a leading substring of the column header. Here is a test script showing various problems.

    [489] cat column.dat
    A25 A17 A1 A33
    1 12 -1 31
    2 13 0 32
    25 17 1 33

    [490] cat column.bug
    print "The following command correctly selects column A17"
    print 'plot "column.dat" using 0:"A17" title columnhead'
    plot 'column.dat' using 0:"A17" title columnhead
    pause -1

    print "In 4.6 this incorrectly selects column A17 but labels it A1"
    print "In 4.7 it works"
    print 'plot "column.dat" using 0:"A1" title columnhead'
    plot 'column.dat' using 0:"A1" title columnhead
    pause -1

    print "In 4.6 this correctly selects column A25"
    print "In 4.7 it dies"
    print 'plot "column.dat" using 0:"A2" title columnhead'
    plot 'column.dat' using 0:"A2" title columnhead
    pause -1

    print "The following command works (sort of) in 4.6 but not 4.7"
    print 'plot "column.dat" using 0:"A" title columnhead'
    plot 'column.dat' using 0:"A" title columnhead
    pause -1

     
  • Ethan Merritt

    Ethan Merritt - 2013-03-15

    Documented and fixed in 4.7 and 4.6.2.
    Note that an exact match is now required, which confused me when testing 4.7 with the above script.

     
  • Ethan Merritt

    Ethan Merritt - 2013-03-15
    • status: open --> closed-fixed
    • milestone: --> 5.0
     

Log in to post a comment.