Re: ValueError: too many values to unpack,>>>

2007-09-28 Thread Bruno Desthuilliers
J. Clifford Dyer a écrit :
> On Thu, Sep 27, 2007 at 09:50:26PM +0200, Bruno Desthuilliers wrote
> regarding Re: ValueError: too many values to unpack,>>>:
>> Shawn Minisall a ?crit :
(snip)
>>> I did and it printed everything up until the 3rd line with 3
>>> numbers for deposits.  I have since figured it out...the teacher
>>> put in an extra tab after the last value so python thought it was
>>> 4 values for three.  I went back into the file and deleted the
>>> extra tab after the 3rd number and saved it...now it's working
>>> fine. I'm going to kill her...

>> You'd better learn how to deal with "this-cant-happen-here"
>> situation, because it's how it is in real-life.
>> 
> 
> And preferably learn how to deal with it in your code, not in the
> data that's given to you.

Thanks for clarifying this point, which is of course what I meant.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ValueError: too many values to unpack

2007-09-27 Thread Pablo Ziliani
Zentrader wrote:
> On Sep 27, 9:46 am, Shawn Minisall <[EMAIL PROTECTED]> wrote:
>   
>> line 3 - 19.1829.1578.75212.10
>> line 4 - 10020410.29
>> And this is the code I'm using:
>>
>>#read withdrawls from file on line3
>>line = infile.readline()
>>  #split withdrawls up
>>withdraw1, withdraw2, withdraw3, withdraw4 = string.split(line, "\t")
>>
>>#read deposits from file on line4
>>line = infile.readline()
>>#split deposits up
>>deposit1, deposit2, deposit3 = string.split(line, "\t")
>>
>> I have 4 strings to match line 3 and 3 to match the 3 on line 4...any
>> thoughts?
>> 
>
> A string.split returns a list so you don't have to know how many
> elements there are beforehand.  A simple example
> withdraw = line.split("\t")
> if len(withdraw) == 3:
>match_3(withdraw)
> elif len(withdraw) == 4::
>match_4(withdraw)
> else:
>print "line.split() is not 3 or 4", withdraw

Right, and then because error was caused for an unexpected extra tab you 
made the deposit pass as a withdrawal...
Not everybody trades just Zen :)

(tip: the unpacking mystery has been solved earlier this day)

Regards,
Pablo
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ValueError: too many values to unpack

2007-09-27 Thread Zentrader
On Sep 27, 9:46 am, Shawn Minisall <[EMAIL PROTECTED]> wrote:
> I am trying to read a few lines of a file with multiple values, the rest
> are single and are reading in fine.
>
> With the multiple value lines, python says this "ValueError: too many
> values to unpack"
>
> I've googled it and it says that happens when you have too few or too
> many strings that don't match with the variables in number your trying
> to assign them too.  Below are the lines in reading in:
>
> line 3 - 19.1829.1578.75212.10
> line 4 - 10020410.29
> And this is the code I'm using:
>
>#read withdrawls from file on line3
>line = infile.readline()
>  #split withdrawls up
>withdraw1, withdraw2, withdraw3, withdraw4 = string.split(line, "\t")
>
>#read deposits from file on line4
>line = infile.readline()
>#split deposits up
>deposit1, deposit2, deposit3 = string.split(line, "\t")
>
> I have 4 strings to match line 3 and 3 to match the 3 on line 4...any
> thoughts?
>
> thx

A string.split returns a list so you don't have to know how many
elements there are beforehand.  A simple example
withdraw = line.split("\t")
if len(withdraw) == 3:
   match_3(withdraw)
elif len(withdraw) == 4::
   match_4(withdraw)
else:
   print "line.split() is not 3 or 4", withdraw

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ValueError: too many values to unpack,>>>

2007-09-27 Thread J. Clifford Dyer
On Thu, Sep 27, 2007 at 09:50:26PM +0200, Bruno Desthuilliers wrote regarding 
Re: ValueError: too many values to unpack,>>>:
> 
> Shawn Minisall a ?crit :
> > Fredrik Lundh wrote:
> > 
> >> Shawn Minisall wrote:
> >>
> >>  
> >>
> >>> Sorry, it looks like it's on the fourth line with the 3 values on 
> >>> line 4...its reading line 3 fine
> >>>
> >>> Traceback (most recent call last):
> >>>   File "", line 1, in 
> >>> main()
> >>>   File "I:\COMPUTER PROGRAMMING CLASS\PROJECT #1\project1.py", line 
> >>> 33, in main
> >>> deposit1, deposit2, deposit3 = string.split(line, "\t")
> >>> ValueError: too many values to unpack
> >>> 
> >>
> >>
> >> instead of fumbling around in the dark, try inserting a print 
> >> statement before the offending line, so you can see what you're trying 
> >> to unpack:
> >>
> >>  print string.split(line, "\t") # see what it is
> >>  deposit1, deposit2, deposit3 = string.split(line, "\t")
> >>
> >> 
> >>   
> > 
> > I did and it printed everything up until the 3rd line with 3 numbers for 
> > deposits.  I have since figured it out...the teacher put in an extra tab 
> > after the last value so python thought it was 4 values for three.  I 
> > went back into the file and deleted the extra tab after the 3rd number 
> > and saved it...now it's working fine.
> > I'm going to kill her...
> 
> You'd better learn how to deal with "this-cant-happen-here" situation, 
> because it's how it is in real-life.
> 

And preferably learn how to deal with it in your code, not in the data that's 
given to you.  I wouldn't be surprised if your teacher gave you that on 
purpose.  There's an old maxim which I think applies here: "Be liberal in what 
you accept and conservative in what you produce."

Note that you have *not* come up with code that handles the dataset given to 
you by your professor.  Do not expect full marks on this homework assignment, 
unless you go back and modify your code to handle extraneous tabs at the end of 
the line.

Cheers,
Cliff

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ValueError: too many values to unpack,>>>

2007-09-27 Thread Steve Holden
Shawn Minisall wrote:
> Fredrik Lundh wrote:
>> Shawn Minisall wrote:
>>
>>   
>>> Sorry, it looks like it's on the fourth line with the 3 values on line 
>>> 4...its reading line 3 fine
>>>
>>> Traceback (most recent call last):
>>>   File "", line 1, in 
>>> main()
>>>   File "I:\COMPUTER PROGRAMMING CLASS\PROJECT #1\project1.py", line 33, 
>>> in main
>>> deposit1, deposit2, deposit3 = string.split(line, "\t")
>>> ValueError: too many values to unpack
>>> 
>> instead of fumbling around in the dark, try inserting a print statement 
>> before the offending line, so you can see what you're trying to unpack:
>>
>>  print string.split(line, "\t") # see what it is
>>  deposit1, deposit2, deposit3 = string.split(line, "\t")
>>
>> 
>>   
> I did and it printed everything up until the 3rd line with 3 numbers for 
> deposits.  I have since figured it out...the teacher put in an extra tab 
> after the last value so python thought it was 4 values for three.  I 
> went back into the file and deleted the extra tab after the 3rd number 
> and saved it...now it's working fine. 
> 
> I'm going to kill her...
> 
> ;)
> 
Alternatively you could use the additional argument to split() that 
tells is the maximum number of splits to [erforms, then strip any 
trailing whitespace off before using the values.

That way tou might get an extra mark for not amending the data file. 
It's called "defensive programming", and you need t take it seriously 
(as does everyone who programs).

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden

Sorry, the dog ate my .sigline

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ValueError: too many values to unpack

2007-09-27 Thread George Sakkis
On Sep 27, 12:46 pm, Shawn Minisall <[EMAIL PROTECTED]> wrote:
> I am trying to read a few lines of a file with multiple values, the rest
> are single and are reading in fine.
>
> With the multiple value lines, python says this "ValueError: too many
> values to unpack"
>
> I've googled it and it says that happens when you have too few or too
> many strings that don't match with the variables in number your trying
> to assign them too.  Below are the lines in reading in:
>
> line 3 - 19.1829.1578.75212.10
> line 4 - 10020410.29
> And this is the code I'm using:
>
>#read withdrawls from file on line3
>line = infile.readline()
>  #split withdrawls up
>withdraw1, withdraw2, withdraw3, withdraw4 = string.split(line, "\t")
>
>#read deposits from file on line4
>line = infile.readline()
>#split deposits up
>deposit1, deposit2, deposit3 = string.split(line, "\t")
>
> I have 4 strings to match line 3 and 3 to match the 3 on line 4...any
> thoughts?
>
> thx

Just print out the split without unpacking to see how many elements
there are actually present:

print string.split(line, "\t")

By the way, most functions of the string module are deprecated in
favor of string methods; the above is better written as

print line.split("\t")


HTH,
George

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ValueError: too many values to unpack,>>>

2007-09-27 Thread Bruno Desthuilliers
Shawn Minisall a écrit :
> Fredrik Lundh wrote:
> 
>> Shawn Minisall wrote:
>>
>>  
>>
>>> Sorry, it looks like it's on the fourth line with the 3 values on 
>>> line 4...its reading line 3 fine
>>>
>>> Traceback (most recent call last):
>>>   File "", line 1, in 
>>> main()
>>>   File "I:\COMPUTER PROGRAMMING CLASS\PROJECT #1\project1.py", line 
>>> 33, in main
>>> deposit1, deposit2, deposit3 = string.split(line, "\t")
>>> ValueError: too many values to unpack
>>> 
>>
>>
>> instead of fumbling around in the dark, try inserting a print 
>> statement before the offending line, so you can see what you're trying 
>> to unpack:
>>
>>  print string.split(line, "\t") # see what it is
>>  deposit1, deposit2, deposit3 = string.split(line, "\t")
>>
>> 
>>   
> 
> I did and it printed everything up until the 3rd line with 3 numbers for 
> deposits.  I have since figured it out...the teacher put in an extra tab 
> after the last value so python thought it was 4 values for three.  I 
> went back into the file and deleted the extra tab after the 3rd number 
> and saved it...now it's working fine.
> I'm going to kill her...

You'd better learn how to deal with "this-cant-happen-here" situation, 
because it's how it is in real-life.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ValueError: too many values to unpack,>>>

2007-09-27 Thread Shawn Minisall
Fredrik Lundh wrote:
> Shawn Minisall wrote:
>
>   
>> Sorry, it looks like it's on the fourth line with the 3 values on line 
>> 4...its reading line 3 fine
>>
>> Traceback (most recent call last):
>>   File "", line 1, in 
>> main()
>>   File "I:\COMPUTER PROGRAMMING CLASS\PROJECT #1\project1.py", line 33, 
>> in main
>>     deposit1, deposit2, deposit3 = string.split(line, "\t")
>> ValueError: too many values to unpack
>> 
>
> instead of fumbling around in the dark, try inserting a print statement 
> before the offending line, so you can see what you're trying to unpack:
>
>  print string.split(line, "\t") # see what it is
>  deposit1, deposit2, deposit3 = string.split(line, "\t")
>
> 
>   
I did and it printed everything up until the 3rd line with 3 numbers for 
deposits.  I have since figured it out...the teacher put in an extra tab 
after the last value so python thought it was 4 values for three.  I 
went back into the file and deleted the extra tab after the 3rd number 
and saved it...now it's working fine. 

I'm going to kill her...

;)

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ValueError: too many values to unpack,>>>

2007-09-27 Thread Fredrik Lundh
Shawn Minisall wrote:

> Sorry, it looks like it's on the fourth line with the 3 values on line 
> 4...its reading line 3 fine
> 
> Traceback (most recent call last):
>   File "", line 1, in 
> main()
>   File "I:\COMPUTER PROGRAMMING CLASS\PROJECT #1\project1.py", line 33, 
> in main
> deposit1, deposit2, deposit3 = string.split(line, "\t")
> ValueError: too many values to unpack

instead of fumbling around in the dark, try inserting a print statement 
before the offending line, so you can see what you're trying to unpack:

 print string.split(line, "\t") # see what it is
 deposit1, deposit2, deposit3 = string.split(line, "\t")



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ValueError: too many values to unpack,>>>

2007-09-27 Thread Shawn Minisall
Marc 'BlackJack' Rintsch wrote:
> On Thu, 27 Sep 2007 12:36:58 -0400, Shawn Minisall wrote:
>
>   
>> With the multiple value lines, python says this "ValueError: too many 
>> values to unpack"
>>
>> I've googled it and it says that happens when you have too few or too 
>> many strings that don't match with the variables in number your trying 
>> to assign them too.  Below are the lines in reading in:
>>
>> line 3 - 19.1829.1578.75212.10
>> line 4 - 10020410.29   
>>
>> And this is the code I'm using:
>>
>> #read withdrawls from file on line3
>> line = infile.readline()
>>
>> #split withdrawls up
>> withdraw1, withdraw2, withdraw3, withdraw4 = string.split(line, "\t")
>>
>> #read deposits from file on line4
>> line = infile.readline()
>> #split deposits up
>> deposit1, deposit2, deposit3 = string.split(line, "\t")
>>
>> I have 4 strings to match line 3 and 3 to match the 3 on line 4...any 
>> thoughts?
>> 
>
> First thought is to find out which of the two lines triggers the
> exception.  This information is part of the full traceback.
>
> Ciao,
>   Marc 'BlackJack' Rintsch
>   

Sorry, it looks like it's on the fourth line with the 3 values on line 
4...its reading line 3 fine

Traceback (most recent call last):
  File "", line 1, in 
main()
  File "I:\COMPUTER PROGRAMMING CLASS\PROJECT #1\project1.py", line 33, 
in main
deposit1, deposit2, deposit3 = string.split(line, "\t")
ValueError: too many values to unpack

-- 
http://mail.python.org/mailman/listinfo/python-list


ValueError: too many values to unpack

2007-09-27 Thread Shawn Minisall
I am trying to read a few lines of a file with multiple values, the rest 
are single and are reading in fine.

With the multiple value lines, python says this "ValueError: too many 
values to unpack"

I've googled it and it says that happens when you have too few or too 
many strings that don't match with the variables in number your trying 
to assign them too.  Below are the lines in reading in:

line 3 - 19.1829.1578.75212.10
line 4 - 10020410.29  
And this is the code I'm using:

   #read withdrawls from file on line3
   line = infile.readline()
 #split withdrawls up
   withdraw1, withdraw2, withdraw3, withdraw4 = string.split(line, "\t")

   #read deposits from file on line4
   line = infile.readline()
   #split deposits up
   deposit1, deposit2, deposit3 = string.split(line, "\t")

I have 4 strings to match line 3 and 3 to match the 3 on line 4...any 
thoughts?

thx
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ValueError: too many values to unpack,>>>

2007-09-27 Thread Marc 'BlackJack' Rintsch
On Thu, 27 Sep 2007 12:36:58 -0400, Shawn Minisall wrote:

> With the multiple value lines, python says this "ValueError: too many 
> values to unpack"
> 
> I've googled it and it says that happens when you have too few or too 
> many strings that don't match with the variables in number your trying 
> to assign them too.  Below are the lines in reading in:
> 
> line 3 - 19.1829.1578.75212.10
> line 4 - 10020410.29   
> 
> And this is the code I'm using:
> 
> #read withdrawls from file on line3
> line = infile.readline()
>
> #split withdrawls up
> withdraw1, withdraw2, withdraw3, withdraw4 = string.split(line, "\t")
> 
> #read deposits from file on line4
> line = infile.readline()
> #split deposits up
> deposit1, deposit2, deposit3 = string.split(line, "\t")
> 
> I have 4 strings to match line 3 and 3 to match the 3 on line 4...any 
> thoughts?

First thought is to find out which of the two lines triggers the
exception.  This information is part of the full traceback.

Ciao,
Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list


ValueError: too many values to unpack,>>>

2007-09-27 Thread Shawn Minisall
I am trying to read a few lines of a file with multiple values, the rest 
are single and are reading in fine.

With the multiple value lines, python says this "ValueError: too many 
values to unpack"

I've googled it and it says that happens when you have too few or too 
many strings that don't match with the variables in number your trying 
to assign them too.  Below are the lines in reading in:

line 3 - 19.1829.1578.75212.10
line 4 - 10020410.29   

And this is the code I'm using:

#read withdrawls from file on line3
line = infile.readline()
   
#split withdrawls up
withdraw1, withdraw2, withdraw3, withdraw4 = string.split(line, "\t")

#read deposits from file on line4
line = infile.readline()
#split deposits up
deposit1, deposit2, deposit3 = string.split(line, "\t")

I have 4 strings to match line 3 and 3 to match the 3 on line 4...any 
thoughts?

thx

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ValueError: too many values to unpack

2007-04-11 Thread Bruno Desthuilliers
Laszlo Nagy a écrit :
(snip)
> Try this instead:
> 
> lineno = 0
> for values in csvreader:
>try:
>   lineno += 1

Laszlo, may I suggest using enumerate() here instead ?-)

for lineno, row in enumerate(csvreader):
   print "line %s" % lineno+1 # want 1-based numbering
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ValueError: too many values to unpack

2007-04-11 Thread fscked
You guys have given me some great ideas, I am going to try them all
out and let you guys know how it turns out.

On a side note, thanks for nto bashing a noob like me who isn't the
greatest pythonista around. I am trying to learn and you guys are how
I learn my mistakes. Well you, and the fact the stuff occasionally
doesn't work. :)

Thanks again and I will report back in a couple hours (meetings).

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ValueError: too many values to unpack

2007-04-11 Thread John Machin
On Apr 12, 5:28 am, "fscked" <[EMAIL PROTECTED]> wrote:
> On Apr 11, 10:26 am, Laszlo Nagy <[EMAIL PROTECTED]> wrote:
>
>
>
> > fscked írta:> Trying to use CSV to read in a line with 11 fields and I keep 
> > getting
> > > this error. I have googled a bit and have been unable to figure it out.
>
> > Probably you have more than 11 values in some (or all) of the rows in
> > the CSV file. Try this code:
>
> > L = (1,2,3,4,5)
> > a1,a2,a3 = L
>
> > If you are sure that you only need a certain number of values, "the
> > first N columns":
>
> > a1,a2,a3 = L[:3]
>
> > Then you still can have a "not enough values to unpack" error, guess
> > what that means. ;-)
>
> >Laszlo
>
> Hmm, well I have counted the fields in the CSV and verified there are
> only 11.

Counted how? Checked each line in the file? Let Python do it; see
below.

> Here is the offending code:
>
> myfile = open('ClientsXMLUpdate.csv')

Put in a second arg of 'rb'; if not the case now, someone might run
your code on Windows some day.

What platform, what version of Python?

> csvreader = csv.reader(myfile)
>
> for boxid, mac, activated, hw_ver, sw_ver, heartbeat, name, address,
> phone, country, city in csvreader:

Not exactly bullet-proof code.

> I just don't get it... :/

Possibly (in one or more rows) the address field has a comma in it and
it's not quoted properly.

Try writing your code in a more defensive fashion:
ENCOLS = 11
rownum = 0
for row in csvreader:
rownum += 1
ancols = len(row)
if ancols != ENCOLS:
print "Row %d has %d columns (expected %d)" \
% (rownum, ancols, ENCOLS)
print row
# pass/return/continue/break/raise/call error logger .
(boxid, mac, activated, hw_ver,
sw_ver, heartbeat, name, address,
phone, country, city) = row

HTH,
John

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ValueError: too many values to unpack

2007-04-11 Thread Gabriel Genellina
En Wed, 11 Apr 2007 16:28:08 -0300, fscked <[EMAIL PROTECTED]>  
escribió:

>> Trying to use CSV to read in a line with 11 fields and I keep getting
>> this error. I have googled a bit and have been unable to figure it
>
> myfile = open('ClientsXMLUpdate.csv')
> csvreader = csv.reader(myfile)
>
> for boxid, mac, activated, hw_ver, sw_ver, heartbeat, name, address,
> phone, country, city in csvreader:
>   mainbox = SubElement(root, "{Boxes}box")
> [...]

You say all rows have 11 fields, the csv module insists on an error... try  
using some print statements to see who is right:

for index, items in enumerate(csvreader):
 print index, len(items)
 if len(items)!=11: print items


-- 
Gabriel Genellina
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ValueError: too many values to unpack

2007-04-11 Thread Laszlo Nagy

> Hmm, well I have counted the fields in the CSV and verified there are
> only 11. Here is the offending code:
>
>   



Try this instead:

lineno = 0
for values in csvreader:
try:
   lineno += 1
   boxid, mac, activated, hw_ver, sw_ver, heartbeat, name, 
address,phone, country, city = values
except:
   print "Problem at line #",lineno
   print repr(values)
   break

Or even:

lineno = 0
for values in csvreader:
   lineno += 1
   if len(values) != 11:
 print "Problem at line #",lineno
 print repr(values)

Best,

   Laszlo

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ValueError: too many values to unpack

2007-04-11 Thread fscked
On Apr 11, 10:26 am, Laszlo Nagy <[EMAIL PROTECTED]> wrote:
> fscked írta:> Trying to use CSV to read in a line with 11 fields and I keep 
> getting
> > this error. I have googled a bit and have been unable to figure it out.
>
> Probably you have more than 11 values in some (or all) of the rows in
> the CSV file. Try this code:
>
> L = (1,2,3,4,5)
> a1,a2,a3 = L
>
> If you are sure that you only need a certain number of values, "the
> first N columns":
>
> a1,a2,a3 = L[:3]
>
> Then you still can have a "not enough values to unpack" error, guess
> what that means. ;-)
>
>Laszlo

Hmm, well I have counted the fields in the CSV and verified there are
only 11. Here is the offending code:

myfile = open('ClientsXMLUpdate.csv')
csvreader = csv.reader(myfile)

for boxid, mac, activated, hw_ver, sw_ver, heartbeat, name, address,
phone, country, city in csvreader:
mainbox = SubElement(root, "{Boxes}box")
mainbox.attrib["city"] = city
mainbox.attrib["country"] = country
mainbox.attrib["phone"] = phone
mainbox.attrib["address"] = address
mainbox.attrib["name"] = name
mainbox.attrib["pl_heartbeat"] = heartbeat
mainbox.attrib["sw_ver"] = sw_ver
mainbox.attrib["hw_ver"] = hw_ver
mainbox.attrib["date_activated"] = activated
mainbox.attrib["mac_address"] = mac
mainbox.attrib["boxid"] = boxid

I just don't get it... :/

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ValueError: too many values to unpack

2007-04-11 Thread Laszlo Nagy
fscked írta:
> Trying to use CSV to read in a line with 11 fields and I keep getting
> this error. I have googled a bit and have been unable to figure it out.
>
>   
Probably you have more than 11 values in some (or all) of the rows in 
the CSV file. Try this code:

L = (1,2,3,4,5)
a1,a2,a3 = L

If you are sure that you only need a certain number of values, "the 
first N columns":

a1,a2,a3 = L[:3]


Then you still can have a "not enough values to unpack" error, guess 
what that means. ;-)

   Laszlo

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ValueError: too many values to unpack

2007-04-11 Thread [EMAIL PROTECTED]
That happens when you try something like this:

a,b,c = [1,2,3,4]

It means there are more items on the right side than the left.  You
probably have < 11 variables on the left side.

On Apr 11, 10:13 am, "fscked" <[EMAIL PROTECTED]> wrote:
> Trying to use CSV to read in a line with 11 fields and I keep getting
> this error. I have googled a bit and have been unable to figure it out.


-- 
http://mail.python.org/mailman/listinfo/python-list


ValueError: too many values to unpack

2007-04-11 Thread fscked
Trying to use CSV to read in a line with 11 fields and I keep getting
this error. I have googled a bit and have been unable to figure it out.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ValueError: too many values to unpack

2006-06-08 Thread k . retheesh
Thank you, that solved my problem.

Thanks
Retheesh

alisonken1 wrote:
> [EMAIL PROTECTED] wrote:
> 
> > 56 records were different
> >  Type,   FileType,
> >Item,
> >  Hash,
> >
> >  Path,  Size,  CullCd,   Ext,  DtCr,
> >  DtLMd, DtLAc
> > Traceback (most recent call last):
> >   File
> > "C:\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py",
> > line 310, in RunScript
> > exec codeObject in __main__.__dict__
> >   File "Q:\PythonScripts\InventoryCompareCase.py", line 234, in ?
> > main()
> >   File "Q:\PythonScripts\InventoryCompareCase.py", line 117, in main
> > for (Type,FileType,Item,Hash,Path,Size,CullCd,Ext,DtCr,DtLMd,DtLAc)
> > in infoDiffs :
> > ValueError: too many values to unpack
> >
> > Thanks
> > Retheesh
>
> The "too many values to unpack" indicates you don't have enough
> variables in the [for (...) in infoDiffs: ] construct.
>
> You also may want to change some of the names; although "Type"
> (variable name) and "type" (python function) should be different, it's
> good practice to not use names that are similar to functions.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ValueError: too many values to unpack

2006-06-08 Thread alisonken1

[EMAIL PROTECTED] wrote:

> 56 records were different
>  Type,   FileType,
>Item,
>  Hash,
>
>  Path,  Size,  CullCd,   Ext,  DtCr,
>  DtLMd, DtLAc
> Traceback (most recent call last):
>   File
> "C:\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py",
> line 310, in RunScript
> exec codeObject in __main__.__dict__
>   File "Q:\PythonScripts\InventoryCompareCase.py", line 234, in ?
> main()
>   File "Q:\PythonScripts\InventoryCompareCase.py", line 117, in main
> for (Type,FileType,Item,Hash,Path,Size,CullCd,Ext,DtCr,DtLMd,DtLAc)
> in infoDiffs :
> ValueError: too many values to unpack
>
> Thanks
> Retheesh

The "too many values to unpack" indicates you don't have enough
variables in the [for (...) in infoDiffs: ] construct.

You also may want to change some of the names; although "Type"
(variable name) and "type" (python function) should be different, it's
good practice to not use names that are similar to functions.

-- 
http://mail.python.org/mailman/listinfo/python-list


ValueError: too many values to unpack

2006-06-08 Thread k . retheesh
Hi,

I am very new to pyton, during my adventures journey I got the
following error message which am not able to solve, can somebody help
me. I was trying to format my output in a readable way,

Compare results in tblItem

71 records found in pctrsqlstage case9125
71 records found in qa-sql2\pctr case9126
Database counts match:  True

71 unique records found in pctrsqlstage case9125
71 unique records found in qa-sql2\pctr case9126
56 records were different
 Type,   FileType,
   Item,
 Hash,

 Path,  Size,  CullCd,   Ext,  DtCr,
 DtLMd, DtLAc
Traceback (most recent call last):
  File
"C:\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py",
line 310, in RunScript
exec codeObject in __main__.__dict__
  File "Q:\PythonScripts\InventoryCompareCase.py", line 234, in ?
main()
  File "Q:\PythonScripts\InventoryCompareCase.py", line 117, in main
for (Type,FileType,Item,Hash,Path,Size,CullCd,Ext,DtCr,DtLMd,DtLAc)
in infoDiffs :
ValueError: too many values to unpack

Thanks
Retheesh

-- 
http://mail.python.org/mailman/listinfo/python-list