error ...1 value to unpack

Chris Mellon arkanes at gmail.com
Fri Nov 2 22:32:27 CET 2007


On Nov 2, 2007 3:04 PM, Beema shafreen <beema.shafreen at gmail.com> wrote:
> hi everybody,
> i have a file:
>
> A_16_P21360207#304
> A_14_P136880#783
> A_16_P21360209#795
> A_16_P21360210#173
> A_16_P03641959#1177
> A_16_P03641960#1944
> A_16_P03641962#999
> A_16_P41563648#-31
> A_16_P03641963#3391
> A_16_P41563649#3626
> A_16_P03641964#180
> A_16_P41563655#1216
> A_16_P03641965#1170
> A_16_P03641966#194
> A_16_P21360229#290
> A_16_P03641967#425
> A_16_P21360231#1091
> A_16_P03641968#1167
> A_16_P03641969#421
> A_16_P03641970#63
> A_16_P21360234#290
> A_16_P21360235#289
> A_16_P03641971#398
> A_16_P21360237#418
> A_16_P03641972#122
> A_16_P21360239#16
> A_16_P03641973#2187
> A_16_P41563669#2881
> A_16_P03641974#1101fh = open('complete_span','r')
> data = fh.readline().split('#')
> old_probe = data[0].strip()
> old_value = data[1].strip()
> #print old_probe, old_value
> count = 1
> while fh:
>         current_probe, current_value = fh.readline().strip().split('#')[0:2]
>         probe  =current_probe.strip()
>         value  = current_value.strip()
>         if old_value > value:
>                 res_value='%s\t%s'%(old_value, old_probe)
>                 print res_value
>         if count == 244000:
>                 break
>         old_probe,old_value =probe, value
> fh.close()
> and i face this error:Traceback (most recent call last):
>   File "count_values.py", line 8, in <module>
>     current_probe, current_value = fh.readline().strip().split('#')[0:2]
> ValueError: need more than 1 value to unpack
>
>
> why do i get this what is the solution for this....
> regards
> shafreen
>

One of your lines doesn't have a # in it, so split is returning a one
element list.



More information about the Python-list mailing list