Skip to content

Commit aee7fe4

Browse files
committed
more work in progress
1 parent 14f0ef1 commit aee7fe4

File tree

5 files changed

+15
-16
lines changed

5 files changed

+15
-16
lines changed
-162 Bytes
Binary file not shown.

src/electricity_network_file_parser/FileParserGen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def parse_property_line(self, property_line : str):
4646
pass
4747

4848
def parse_entities(self, lines : List[str], property_attributes_to_parse : List[str]):
49-
pass
49+
return self.text_parser.parse_entities(lines, property_attributes_to_parse)
5050

5151
def create_entity_dict(self, lines):
5252
entity_indices = [i for i, line in enumerate(lines) if line.strip().startswith("[") and line.strip().endswith("]")]

src/electricity_network_file_parser/GnfParser.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from enum import Enum
22
import pandas as pd
3-
from electricity_network_file_parser import FileParserGen
3+
from electricity_network_file_parser.FileParserGen import FileParserGen
44
from electricity_network_file_parser.TextParser7x import TextParser7x
55
from electricity_network_file_parser.TextParser8x import TextParser8x
66
from electricity_network_file_parser.dataclasses import EntityDescription7x
@@ -13,12 +13,12 @@ class GnfParser(FileParserGen):
1313

1414
def __init__(self, file_path):
1515
super().__init__(file_path)
16-
if VersionNumber.G7 in self.version_string:
16+
if VersionNumber.G8.value in self.version_string:
1717
self.version_number = VersionNumber.G8
18-
self.text_parser = TextParser8x(file_path)
19-
elif VersionNumber.G8 in self.version_string:
18+
self.text_parser = TextParser8x()
19+
elif VersionNumber.G7.value in self.version_string:
2020
self.version_number = VersionNumber.G7
21-
self.text_parser = TextParser7x(file_path)
21+
self.text_parser = TextParser7x()
2222

2323
if self.text_parser is None:
2424
raise ValueError("Unsupported file format. Only G7 and G8 files are supported.")
@@ -48,14 +48,15 @@ def __init__(self, file_path):
4848
EntityDescription7x(3, ["shortname", "Unom", "price", "C", "C0", "Inom0", "G1", "Inom1", "G2", "Inom2", "G3", "Inom3", "Ik1s", "TR", "TInom", "TIk1s", "frequency", "r_g", "x_g", "r_gg_n", "x_ggf_n", "r_gg_t", "x_gg_t", "r_a", "x_a", "r_ga", "x_ga", "r_h", "x_h", "r_gh_n", "x_gh_n", "r_gh_t", "x_gh_t", "r_hh_n", "x_hh_n", "r_hh_t", "x_hh_t", "r_ha", "x_ha", "Inom_a", "Ik1s_a", "Inom_h", "Ik1s_h", "r_g/r_n"])
4949
],
5050
"TRANSFORMER" : [
51-
EntityDescription7x(1, ["nr", "revision", "knr1", "knr2", "naam", "s1_l1", "s1_l2", "s1_l3", "s1_n", "s1_pe", "s2_l1", "s2_l2", "s2_l3", "s2_n", "s2_pe", "veld1", "veld2", "faalfrequentie", "trafotype", "s_n_pe", "s_pe_a", "Ra", "trapstand", "regelingstatus", "meetzijde", "regelknoopnr", "Uset", "Uband", "regelingsoort", "Rc", "Xc", "terugc", "Pmin", "Umin", "Pmax", "Umax"]),
52-
EntityDescription7x(2, ["kortenaam", "Snom", "Unom1", "Unom2", "Uk", "Pk", "Pnul", "Inul", "R0", "Z0", "Ik2s", "schak1", "schak2", "klok", "trapzijde", "trapgrootte", "trapmin", "trapnom", "trapmax", "regelbaar"]),
51+
EntityDescription7x(1, ["number", "revision", "knr1", "knr2", "name", "s1_l1", "s1_l2", "s1_l3", "s1_n", "s1_pe", "s2_l1", "s2_l2", "s2_l3", "s2_n", "s2_pe", "veld1", "veld2", "failurefrequency", "trafotype", "s_n_pe", "s_pe_a", "Ra", "trapstand", "regelingstatus", "meetzijde", "regelknoopnr", "Uset", "Uband", "regelingsoort", "Rc", "Xc", "terugc", "Pmin", "Umin", "Pmax", "Umax"]),
52+
EntityDescription7x(2, ["shortname", "Snom", "Unom1", "Unom2", "Uk", "Pk", "Pnul", "Inul", "R0", "Z0", "Ik2s", "schak1", "schak2", "klok", "trapzijde", "trapgrootte", "trapmin", "trapnom", "trapmax", "regelbaar"]),
5353
],
54-
"SOURCE" : ["General"],
55-
"LOAD" : ["General"],
56-
"HOME" : ["General", "ConnectionCableType", "FuseType"],
57-
"MEASURE FIELD" : ["General"],
58-
"FUSE": ["General"]
54+
"SOURCE" : [EntityDescription7x(1, ["1", "knr", "subnr", "revision", "naam", "s_l1", "s_l2", "s_l3", "s_n", "veld", "Umin", "Umax", "Uprofile", "Sk'nom", "profilenumber", "failurefrequency"])],
55+
"LOAD" : [EntityDescription7x(1, ["knr", "subnr", "revision", "name", "s_l1", "s_l2", "s_l3", "s_n", "veld", "Pa", "Qa", "Pb", "Qb", "Pc", "Qc", "Pab", "Qab", "Pac", "Qac", "Pbc", "Qbc", "gedragsoort", "groeinr", "profielnr", "harmonischentype", "inschakelfrequentie", "piektomgekeerd"])],
56+
"HOME" : [
57+
EntityDescription7x(1, ["knr", "subnr", "revision", "name", "s_l1", "s_l2", "s_l3", "s_n", "veld", "s_pe", "k_1", "k_2", "k_3", "length", "cabletype", "aardingsconfiguratie", "sh_n_pe", "sh_pe_pe", "sh_pe_a", "Ra", "sh_h", "smeltveiligheidtype", "stroomtype", "fasen", "soort", "aansluitwaarde", "Iaardlek", "risico", "gx", "gy", "adres", "postcode", "woonplaats"]),
58+
EntityDescription7x(2, ["shortname", "Unom", "price", "C", "C0", "Inom0", "G1", "Inom1", "G2", "Inom2", "G3", "Inom3", "Ik1s", "TR", "TInom", "TIk1s", "frequency", "r_g", "x_g", "r_gg_n", "x_ggf_n", "r_gg_t", "x_gg_t", "r_a", "x_a", "r_ga", "x_ga", "r_h", "x_h", "r_gh_n", "x_gh_n", "r_gh_t", "x_gh_t", "r_hh_n", "x_hh_n", "r_hh_t", "x_hh_t", "r_ha", "x_ha", "Inom_a", "Ik1s_a", "Inom_h", "Ik1s_h", "r_g/r_n"])
59+
]
5960
}
6061

6162
def parse_cable_types(self, cables_df : pd.DataFrame) -> pd.DataFrame:

src/electricity_network_file_parser/TextParser8x.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
from electricity_network_file_parser.dataclasses import PropertyDescription
88

99
class TextParser8x:
10-
def __init__(self, file_path):
11-
super().__init__(file_path)
1210

1311
def parse_property_line(self, property_line : str):
1412
property_name = property_line[1: property_line.index(" ")]

test/TestGnfParser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
class Test(unittest.TestCase):
77

88
def setUp(self):
9-
self.gnf_parser = GnfParser("test.gnf")
9+
self.gnf_parser = GnfParser("test/test.gnf")
1010

1111
def test_gnf_parser(self):
1212
self.gnf_parser.parse_file()

0 commit comments

Comments
 (0)