python - Why does takewhile() skip the first line? -
I have a file:
1 2 3 tab 1 2 3 tab I want to read the block between tabs as blocks.
import itertools def block_generator (file): in the form of lines with open (file): line for line: block = list (iterolls.cavion x: x.rstrip ('\ N ')! =' \ T ', lines)) The output block I want to use it like: block = block_generator (mime) for block block:
The blocks are starting from the second line like all of me [2,3] [2,3] , why?
From the DRA block_generator (filename) here via group
Another method is to use the group: as lines with open (filename): for pred, block by group (line, "\ t \ n" .__ ne__): if future: yield block
Comments
Post a Comment