mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
creating non-invasive survey results WIP
This commit is contained in:
parent
94f9979f56
commit
d8caacae97
4 changed files with 134 additions and 2 deletions
2
.idea/Model.iml
generated
2
.idea/Model.iml
generated
|
|
@ -7,7 +7,7 @@
|
|||
<sourceFolder url="file://$MODULE_DIR$/open_uprn" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/recommendations" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="Python 3.10 (backend)" jdkType="Python SDK" />
|
||||
<orderEntry type="jdk" jdkName="Python 3.10 (model_data)" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
<component name="PyNamespacePackagesService">
|
||||
|
|
|
|||
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
|
|
@ -3,7 +3,7 @@
|
|||
<component name="Black">
|
||||
<option name="sdkName" value="Python 3.10 (backend)" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (backend)" project-jdk-type="Python SDK" />
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (model_data)" project-jdk-type="Python SDK" />
|
||||
<component name="PythonCompatibilityInspectionAdvertiser">
|
||||
<option name="version" value="3" />
|
||||
</component>
|
||||
|
|
|
|||
131
etl/customers/immo/pilot/non_invasive.py
Normal file
131
etl/customers/immo/pilot/non_invasive.py
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
import extract_msg
|
||||
|
||||
|
||||
def parse_msg_body(text):
|
||||
# Split the text into lines
|
||||
lines = text.split('\r\n')
|
||||
|
||||
# Dictionary to hold the parsed data
|
||||
data = {}
|
||||
|
||||
# Process each line
|
||||
for line in lines:
|
||||
# Remove all asterisks and extra whitespace
|
||||
clean_line = line.replace('*', '').strip()
|
||||
|
||||
if clean_line: # Ensure the line is not empty after cleaning
|
||||
# Attempt to split clean '=' if present
|
||||
if '=' in clean_line:
|
||||
clean_line = clean_line.replace(' = ', ': ')
|
||||
|
||||
# Use line content as a key with a default value indicating presence
|
||||
# Generate a unique key for lines without '='
|
||||
data[f"Info{len(data) + 1}"] = clean_line
|
||||
|
||||
return data
|
||||
|
||||
|
||||
def app():
|
||||
"""
|
||||
This code retrieves the results of the non-invasive surveys, to be stored in S3
|
||||
:return:
|
||||
"""
|
||||
|
||||
# filepath = ("/Users/khalimconn-kowlessar/Downloads/IMMO - Dudley Pilot - non-invasive raw data/5 Oaklands B62 "
|
||||
# "0JA/Immo - 5 Oaklands Halesowen B62 0JA.msg")
|
||||
# filepath = ("/Users/khalimconn-kowlessar/Downloads/IMMO - Dudley Pilot - non-invasive raw data/6 Beech Rd DY1 "
|
||||
# "4BP/IMMO - 6 Beech Road Dudley DY1 4BP.msg")
|
||||
# filepath = (
|
||||
# "/Users/khalimconn-kowlessar/Downloads/IMMO - Dudley Pilot - non-invasive raw data/8 Corporation Rd DY2 "
|
||||
# "7PX/IMMO - 8 Corporation Road Dudley DY2 7PX.msg"
|
||||
# )
|
||||
# filepath = (
|
||||
# "/Users/khalimconn-kowlessar/Downloads/IMMO - Dudley Pilot - non-invasive raw data/21 Wells Rd DY5 3TB/"
|
||||
# "IMMO - 21 Wells Road Brierley Hill DY5 3TB.msg"
|
||||
# )
|
||||
filepath = (
|
||||
"/Users/khalimconn-kowlessar/Downloads/IMMO - Dudley Pilot - non-invasive raw data/47 Fairfield Rd DY8 "
|
||||
"5UJ/IMMO - 47 Fairfield Road Wordsley Stourbridge DY8 5UJ.msg"
|
||||
)
|
||||
|
||||
with extract_msg.Message(filepath) as msg:
|
||||
sender = msg.sender
|
||||
recipients = msg.to
|
||||
subject = msg.subject
|
||||
body = msg.body
|
||||
# If the msg has attachments, they can be extracted as well
|
||||
attachments = msg.attachments
|
||||
|
||||
from pprint import pprint
|
||||
pprint(parse_msg_body(body))
|
||||
|
||||
# We manually create the non-invasive notes for the pilot
|
||||
non_invasive_notes = [
|
||||
{
|
||||
'address': '5 Oaklands',
|
||||
'postcode': 'B62 0JA',
|
||||
'Surveyor': 'Carl Fitzgerald - The Warmfront Team',
|
||||
'Wall Insulation': 'Cavity wall, retro drilled, containing loose fibre insulation. Consider getting a '
|
||||
'CIGA check and extracting the cavity, replacing with bead insulation. '
|
||||
'There is a shared alleyway with the neighbour, that is a solid brick wall.',
|
||||
'Wall Render': 'Partial render between top of ground floor window and bottom of 1st floor window',
|
||||
'Existing solar PV': 'No existing solar',
|
||||
'Orientation': 'Front house direction: North East, Back house direction: South West',
|
||||
'Access to mains?': 'Property has access to the mains',
|
||||
},
|
||||
{
|
||||
'address': '6 Beech Road',
|
||||
'postcode': 'DY1 4BP',
|
||||
'Surveyor': 'Carl Fitzgerald - The Warmfront Team',
|
||||
'Wall Insulation': '1st floor is solid brick with external wall insulation. 2nd floor is cavity, '
|
||||
'retro drilled, containing loose fibre insulation. Consider getting a '
|
||||
'CIGA check and extracting the cavity, replacing with bead insulation.',
|
||||
'Wall Render': None,
|
||||
'Existing solar PV': 'No existing solar',
|
||||
'Orientation': 'Side house direction: North East',
|
||||
'Access to mains?': 'Property has access to the mains',
|
||||
},
|
||||
{
|
||||
'address': '8 Corporation Road',
|
||||
'postcode': 'DY2 7PX',
|
||||
'Surveyor': 'Carl Fitzgerald - The Warmfront Team',
|
||||
'Wall Insulation': "External wall insulation",
|
||||
'Wall Render': "Render finish throughout",
|
||||
'Existing solar PV': 'No existing solar',
|
||||
'Orientation': 'Front house direction: North East, Back house direction: South West',
|
||||
'Access to mains?': None,
|
||||
},
|
||||
{
|
||||
|
||||
'address': '21 Wells Road',
|
||||
'postcode': 'DY5 3TB',
|
||||
'Surveyor': 'Carl Fitzgerald - The Warmfront Team',
|
||||
'Wall Insulation': 'Cavity wall, retro drilled, containing loose fibre insulation. Consider getting a '
|
||||
'CIGA check and extracting the cavity, replacing with bead insulation.',
|
||||
'Wall Render': None,
|
||||
'Existing solar PV': 'No existing solar',
|
||||
'Orientation': 'Front house direction: East, Back house direction: West',
|
||||
'Access to mains?': 'Property has access to the mains',
|
||||
},
|
||||
{
|
||||
'address': '47 Fairfield Road',
|
||||
'postcode': 'DY8 5UJ',
|
||||
'Surveyor': 'Carl Fitzgerald - The Warmfront Team',
|
||||
'Wall Insulation': 'Cavity wall, retro drilled, containing loose fibre insulation. Consider getting a '
|
||||
'CIGA check and extracting the cavity, replacing with bead insulation.',
|
||||
'Wall Render': None,
|
||||
'Existing solar PV': 'No existing solar',
|
||||
'Orientation': 'Front house direction: East, Back house direction: West',
|
||||
'Access to mains?': 'Property has access to the mains',
|
||||
},
|
||||
{
|
||||
'address': None,
|
||||
'postcode': None,
|
||||
'Surveyor': 'Carl Fitzgerald - The Warmfront Team',
|
||||
'Wall Insulation': None,
|
||||
'Wall Render': None,
|
||||
'Existing solar PV': None,
|
||||
'Orientation': None,
|
||||
'Access to mains?': None,
|
||||
},
|
||||
]
|
||||
1
etl/customers/immo/pilot/requirements.txt
Normal file
1
etl/customers/immo/pilot/requirements.txt
Normal file
|
|
@ -0,0 +1 @@
|
|||
extract-msg
|
||||
Loading…
Add table
Reference in a new issue