The better way to read a formated data from .TXT file strings in Python

I have a following quest:
There is an unmarked text file in the .TXT format of the following structure:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>City name is Paris
It was build in 303 BD
NORTH PART
Size 56% of city
QUATERS
Quarter name Saint-Ouen
Size Big
Quarter name Saint-Denis
Size Medium
STREETS
Street name Napoleon's Av.
Number of houses 78
Is located in Saint-Ouen
ZipCode 001-020
Street name Republic st.
Number of houses 101
Is located in Saint-Ouen
ZipCode 031-039
CITIZENS
Hello! My name is Peter, i'm 29 years old. I live in Napoleon's Av. in 45 house, flat 5, room 111. I am office worker
Hello! My name is Helen, i'm 23 years old. I live in Napoleon's Av. in 45 house, flat 1, room 90. I am office worker and mother
Hello! My name is Pole, i'm 33 years old. I live in Republic st. in 100 house, flat 10, room 300. I am gardener, artist and freelancer
SOUTH PART
Size 44% of city
~same story~
</code>
<code>City name is Paris It was build in 303 BD NORTH PART Size 56% of city QUATERS Quarter name Saint-Ouen Size Big Quarter name Saint-Denis Size Medium STREETS Street name Napoleon's Av. Number of houses 78 Is located in Saint-Ouen ZipCode 001-020 Street name Republic st. Number of houses 101 Is located in Saint-Ouen ZipCode 031-039 CITIZENS Hello! My name is Peter, i'm 29 years old. I live in Napoleon's Av. in 45 house, flat 5, room 111. I am office worker Hello! My name is Helen, i'm 23 years old. I live in Napoleon's Av. in 45 house, flat 1, room 90. I am office worker and mother Hello! My name is Pole, i'm 33 years old. I live in Republic st. in 100 house, flat 10, room 300. I am gardener, artist and freelancer SOUTH PART Size 44% of city ~same story~ </code>
City name is Paris
It was build in 303 BD

 NORTH PART
 Size 56% of city
 QUATERS
 Quarter name Saint-Ouen
 Size Big
 
 Quarter name Saint-Denis
 Size Medium

 STREETS
 Street name  Napoleon's Av.
 Number of houses 78
 Is located in Saint-Ouen
 ZipCode 001-020

 Street name  Republic st.
 Number of houses 101
 Is located in Saint-Ouen
 ZipCode 031-039

 CITIZENS
 Hello! My name is Peter, i'm 29 years old. I live in Napoleon's Av. in 45 house, flat 5, room 111. I am office worker

 Hello! My name is Helen, i'm 23 years old. I live in Napoleon's Av. in 45 house, flat 1, room 90. I am office worker and mother

 Hello! My name is Pole, i'm 33 years old. I live in Republic st. in 100 house, flat 10, room 300. I am gardener, artist and freelancer

 SOUTH PART
 Size 44% of city
  ~same story~

So I want to deserialize this file for eaier data manipulation into dict and/or SQL database.
Those files have ~5000 lines for 1 city and ~1000 cities in total.

I’ve created dataclasses for data storage

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>@dataclass
class CitizenData:
name: str
age: int
street: str
house: str #because it can be like "45B"
flat: int
room: int
jobs: list[str] = field(default_factory=list)
@dataclass
class StreetData:
name: str
houses_located: int
zip_code_min: int
zip_code_max: int
citizens:list[CitizenData] = field(default_factory=list)
class QuaterSize(Enum):
SMALL=1
MEDIUM = 2
BIG = 3
@dataclass
class QuarterData:
name: str
size: QuaterSize
streets: list[StreetData] = field(default_factory=list)
@dataclass
class CityPartData:
name: str
procent_of_city_size: float
quarters: list[QuarterData] = field(default_factory=list)
@dataclass
class City:
name: str
year_of_foundation: int
city_parts: list[CityPartData] = field(default_factory=list)
</code>
<code>@dataclass class CitizenData: name: str age: int street: str house: str #because it can be like "45B" flat: int room: int jobs: list[str] = field(default_factory=list) @dataclass class StreetData: name: str houses_located: int zip_code_min: int zip_code_max: int citizens:list[CitizenData] = field(default_factory=list) class QuaterSize(Enum): SMALL=1 MEDIUM = 2 BIG = 3 @dataclass class QuarterData: name: str size: QuaterSize streets: list[StreetData] = field(default_factory=list) @dataclass class CityPartData: name: str procent_of_city_size: float quarters: list[QuarterData] = field(default_factory=list) @dataclass class City: name: str year_of_foundation: int city_parts: list[CityPartData] = field(default_factory=list) </code>
@dataclass
class CitizenData:
   name: str
   age: int
   street: str
   house: str #because it can be like "45B"
   flat: int
   room: int
   jobs: list[str] = field(default_factory=list)


@dataclass
class StreetData:
   name: str
   houses_located: int
   zip_code_min: int
   zip_code_max: int
   citizens:list[CitizenData] = field(default_factory=list)


class QuaterSize(Enum):
   SMALL=1
   MEDIUM = 2
   BIG = 3


@dataclass
class QuarterData:
   name: str
   size: QuaterSize
   streets: list[StreetData] = field(default_factory=list)


@dataclass
class CityPartData:
   name: str
   procent_of_city_size: float
   quarters: list[QuarterData] = field(default_factory=list)

@dataclass
class City:
   name: str
   year_of_foundation: int
   city_parts: list[CityPartData] = field(default_factory=list)
   

And now I’m wondering: is there any elegant and pythonic way to fill those classes with data from file? I’ve tried to search for kind of “formated reading” (like f-strings but with data gathering instead of data presenting) and found nothing. Only JSON and XML handling by special libs and nothing for this type of problems.
Slicing the string lines looks barbaric but it is only type of solution I have on mind.

I want to make this program clean and easy supportable but I’m lake of python and architecture experience to be sure how to do it

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật