Changeset 6477


Ignore:
Timestamp:
Mar 10, 2009, 10:26:25 AM (16 years ago)
Author:
rwilson
Message:

Fixed bug whereby spaces in CSV header strings crashed the application.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • misc/tools/plotcsv/plotcsv.py

    r6358 r6477  
    162162def error(msg):
    163163    print msg
     164    import tkinter_error
     165    tkinter_error.tkinter_error(msg)
    164166    sys.exit(10)
    165167
     
    167169################################################################################
    168170# An object that behaves like a dictionary but is pickled/unpickled from a file.
     171# Used to save state in the application.
    169172################################################################################
    170173
     
    279282    del data[0]         # get rid of header in dataset
    280283
     284    # ensure header strings don't have leading/trailing spaces
     285    new_header = []
     286    for h in header:
     287        new_header.append(h.strip())
     288    header = new_header
     289
    281290    # get int index values for column headers
    282291    try:
    283292        x_index = header.index(x_hdr)
    284293    except ValueError:
    285         error("Sorry, X column header '%s' isn't in the data file." % x_hdr)
     294        error("Sorry, X column header '%s' isn't in data file '%s'."
     295              % (x_hdr, filename))
    286296
    287297    try:
    288298        y_index = header.index(y_hdr)
    289299    except ValueError:
    290         error("Sorry, Y column header '%s' isn't in the data file." % y_hdr)
     300        error("Sorry, Y column header '%s' isn't in data file '%s'."
     301              % (y_hdr, filename))
    291302
    292303    # get appropriate columns from data[]
     
    329340            legend_names = [os.path.basename(x) for x in filenames]
    330341        pylab.legend(legend_names, 'upper right')
    331 #        pylab.legend(legend_names, 'upper left')
    332342
    333343    pylab.show()
    334 #    pylab.close()
     344    pylab.close()
    335345
    336346
Note: See TracChangeset for help on using the changeset viewer.