Python Forum

Full Version: Extracting Reoccuring Row Titles
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Good Evening!

I've got basic python education but am working on my capabilities.

I'm attempting to parse out multiple data entries for a single series of rows that contain headings. I just want the data within the row, not the heading. Here is an example of the raw data, which is much-much longer in real life.


RAW DATA SET:
1: Jeff
2: 21
3: Mature
4: Another
5: Yo

1: Sarah
2: Girl
3: Friend
4: Fall
5: Test

1: Fred
2: Hey
3: No
4: Window
5: Fifty...

DESIRED OUTPUT: (Print rows that begin with 1 and 3)

Jeff
Mature

Sarah
Friend

Fred
No


Where I'm at with my code testing.

TextDoc = '/root/Documents/<docname>.txt'

f = open(TextDoc, 'r')

if 1 print.line
if 3 print.line

f.close()



Thanks in advance for any mentorship,

-Hier0phant
For this I would use the startswith, split, and strip methods of strings.