I have a text file with some rows shifted over one tab, signifying that they are a subcategory of the main row. I need to label each row with a unique label signifying which "group" or category they belong to in order to do statistical analysis on each category.
I'm not too sure how to automate this in Python, as there are thousands of rows in the file. I am unable to convert the file into a csv without first shifting over all the indented rows, which would obviously lose any ability to tell which category each row falls into.
EDIT:
Here is a screenshot of a sample text file that shows what I am talking about visually.
The first 3 rows would have group label "1", the next 2 rows would have label "2", and the last 2 rows would have labels "3" and "4" respectively.