Please help with problem creating class
Günther Dietrich
guenther.dietrich at spamfence.net
Sat Apr 18 15:37:39 EDT 2009
auzarski2008 at gmail.com wrote:
>I am using tab separated data in another file that looks like this...
>
>
>appname1 leadername1 2005, 02, 02 2006, 02, 02
>appname2 leadername2 2006, 03, 21 2007, 06, 28
>
>etc...
>
>The error message looks like this....
>
> back (most recent call last):
> File "/home/amy/Documents/LIS452/assignment 3/testworks.py", line
>97, in <module>
> main()
> File "/home/amy/Documents/LIS452/assignment 3/testworks.py", line
>80, in main
> a = Leaderapplicant(line) #from data file
> File "/home/amy/Documents/LIS452/assignment 3/testworks.py", line 9,
>in __init__
> appname, leadername, start, end = line.split("\t")
>ValueError: need more than 3 values to unpack
You assign the result of line.split() to four variables. So split needs
at least four fields (that's more than three) in line to process.
Examine your input data ("appname1 leadername1 2005..."), if it
_really_ contains alt least three tab characters to separate the data
fields.
Maybe you created the input file by means of the same editor you use for
coding your python code, so the probability is high, that the editor
produces multiple space characters when you press the tab key.
You could load the input file into vi or vim and give vi/vim the command
:set list
In list mode, tabs are rendered as '^I' (without the quotes).
Or you use a hex editor or something like od to inspect the input file.
Best regards,
Günther
More information about the Python-list
mailing list