mirror of
https://github.com/Hestia-Homes/survey-extraction.git
synced 2026-06-30 13:10:56 +00:00
use formula to get each section correctly
This commit is contained in:
parent
7aa694a5ff
commit
2fbc330c7c
1 changed files with 20 additions and 25 deletions
|
|
@ -238,7 +238,7 @@ class QuidosSiteNotes(SiteNotes):
|
||||||
|
|
||||||
def get_section_7(self):
|
def get_section_7(self):
|
||||||
data = self.raw_data[self.raw_data.index('7.0 Walls'): self.raw_data.index('8.0 Roofs')]
|
data = self.raw_data[self.raw_data.index('7.0 Walls'): self.raw_data.index('8.0 Roofs')]
|
||||||
avoid = [
|
sub_titles = [
|
||||||
"Construction",
|
"Construction",
|
||||||
"Insulation",
|
"Insulation",
|
||||||
"Insulation Thickness(mm)",
|
"Insulation Thickness(mm)",
|
||||||
|
|
@ -253,24 +253,18 @@ class QuidosSiteNotes(SiteNotes):
|
||||||
"Alternative Wall Present",
|
"Alternative Wall Present",
|
||||||
]
|
]
|
||||||
|
|
||||||
get_value = lambda key: None if self.raw_data[self.raw_data.index(key) + 1] in avoid else self.raw_data[self.raw_data.index(key) + 1]
|
main_titles = [
|
||||||
|
"Main Property",
|
||||||
# Main property
|
"Extension 1",
|
||||||
main_info = data[data.index("Main Property"):data.index("Extension 1")]
|
"Extension 2",
|
||||||
for i,item in enumerate(main_info):
|
"Extension 3",
|
||||||
if item in avoid:
|
"Extension 4",
|
||||||
setattr(self, f"main_property_{item.lower().replace(' ', '_').replace('-', '_')}", get_value(item))
|
]
|
||||||
|
self.two_column_with_extension_processor(data, sub_titles, main_titles, 7)
|
||||||
for j in range(1, 5):
|
|
||||||
main_data = data[data.index(f"Extension {j}"):]
|
|
||||||
get_value = lambda key: None if main_data[main_data.index(key) + 1] in avoid else main_data[main_data.index(key) + 1]
|
|
||||||
for i,item in enumerate(main_data):
|
|
||||||
if item in avoid:
|
|
||||||
setattr(self, f"extensions_{j}_{item.lower().replace(' ', '_').replace('-', '_')}", get_value(item))
|
|
||||||
|
|
||||||
def get_section_8(self):
|
def get_section_8(self):
|
||||||
data = self.raw_data[self.raw_data.index('8.0 Roofs'): self.raw_data.index('9.0 Floors')]
|
data = self.raw_data[self.raw_data.index('8.0 Roofs'): self.raw_data.index('9.0 Floors')]
|
||||||
avoid = [
|
sub_titles = [
|
||||||
"Construction",
|
"Construction",
|
||||||
"Insulation Type",
|
"Insulation Type",
|
||||||
"Insulation Thickness",
|
"Insulation Thickness",
|
||||||
|
|
@ -285,25 +279,26 @@ class QuidosSiteNotes(SiteNotes):
|
||||||
"Extension 4",
|
"Extension 4",
|
||||||
]
|
]
|
||||||
|
|
||||||
self.two_column_with_extension_processor(data, avoid, titles, 8)
|
self.two_column_with_extension_processor(data, sub_titles, titles, 8)
|
||||||
|
|
||||||
|
def two_column_with_extension_processor(self, data, sub_titles, main_titles, section):
|
||||||
|
|
||||||
def two_column_with_extension_processor(self, data, avoid, titles, section):
|
|
||||||
title = None
|
title = None
|
||||||
proc_data = data
|
proc_data = data
|
||||||
for items in data:
|
for items in data:
|
||||||
if items in titles:
|
if items in main_titles:
|
||||||
title = items.lower().replace(" ", "_").replace("-", "_")
|
title = items.lower().replace(" ", "_").replace("-", "_")
|
||||||
index = titles.index(items)
|
index = main_titles.index(items)
|
||||||
if titles[index] in data:
|
if main_titles[index] in data:
|
||||||
print(titles[index])
|
print(main_titles[index])
|
||||||
proc_data = data[data.index(titles[index]):]
|
proc_data = data[data.index(main_titles[index]):]
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
if title is None:
|
if title is None:
|
||||||
continue
|
continue
|
||||||
get_value = lambda key: None if proc_data[proc_data.index(key) + 1] in avoid else proc_data[proc_data.index(key) + 1]
|
get_value = lambda key: None if proc_data[proc_data.index(key) + 1] in sub_titles else proc_data[proc_data.index(key) + 1]
|
||||||
if items in avoid:
|
if items in sub_titles:
|
||||||
setattr(self, f"section_{section}_{title}_{items.lower().replace(' ', '_').replace('-','_')}", get_value(items))
|
setattr(self, f"section_{section}_{title}_{items.lower().replace(' ', '_').replace('-','_')}", get_value(items))
|
||||||
|
|
||||||
def get_section_9(self):
|
def get_section_9(self):
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue