I have a code meant to strim a string within a large text file. When I run it an error message shows up "ValueError: need more than 1 value to unpack". So I changed the integer for 0, 1 and 2 in this line :
_, k = line.split('\t',1)
If I input 2 it says 'Too many value to unpack'. I tried to define each variable as follow :
f = []
_ = []
k = []
x = []
i = 0
.. That didn't work out either.
Here is the code:
# Opens each file to read/modify
infile='110331_HS1A_1_rtTA.result'
outfile='2.txt'
#import Regex
import re
with open (infile, mode='r', buffering=-1) as in_f, open (outfile, mode='w', buffering=-1) as out_f:
f = (i for i in in_f if i.rstrip())
for line in f:
_, k = line.split('\t',1)
x = re.findall(r'^1..100\t([+-])chr(\d+):(\d+)\.\.(\d+).+$',k)
if not x:
continue
out_f.write(' '.join(x[0]) + '\n')
Here is the error :
Traceback (most recent call last):
File "C:\DB\Stack Overflow\test5.py", line 11, in <module>
_, k = line.split('\t',1)
ValueError: need more than 1 value to unpack
Thanks for those who are willing to help/teach me :)