importCIGREMV.py 887 Bytes
Newer Older
1
2
import logging
import cimpy
3
from pathlib import Path
4

5
logging.basicConfig(filename='importCIGREMV.log', level=logging.INFO, filemode='w')
6

7
example = Path(__file__).resolve().parent
8
9

# called as cimpy.examples.import_example() or file run from quickstart directory?
10
if 'cimexamples.py' in str(__file__):
11
12
13
    sample_folder = example / 'examples' / 'sampledata' / 'CIGRE_MV'
else:
    sample_folder = example / 'sampledata' / 'CIGRE_MV'
14
print(sample_folder)
15
sample_files = sample_folder.glob('*.xml')
16
print(sample_files)
17
18
19
xml_files = []
for file in sample_folder.glob('*.xml'):
    xml_files.append(str(file.absolute()))
20

21
import_result = cimpy.cim_import(xml_files, "cgmes_v2_4_15")
22
23
print("\n\n")
results = ["ACLineSegment", "PowerTransformer", "EnergyConsumer"]
24
for key, value in import_result['topology'].items():
25
26
    if value.__class__.__name__ in results:
        print(value.__str__())