Skip to content

Tag: text-processing

How can I loop through blocks of lines in a file?

I have a text file that looks like this, with blocks of lines separated by blank lines: How can I loop through the blocks and process the data in each block? eventually I want to gather the name, family name and age values into three columns, like so: Answer Here’s another way, using itertools.groupby. …