Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New cycle csv parser #120

Merged
merged 5 commits into from
Dec 9, 2024
Merged

New cycle csv parser #120

merged 5 commits into from
Dec 9, 2024

Conversation

tinogis
Copy link
Member

@tinogis tinogis commented Dec 5, 2024

New class CycleFile to parse csv cycle results generated by data concentrators.

starting cycle Ciclo_instant_data_minute at 2024/11/29 11:23:35
time;dev_sn;operation;obis;class_id;element_id;result;action return
2024/11/29 11:23:36;SAG0155349819;get;0.0.21.0.5.255;7;2;array{structure{octet_string{2024/11/29 11:23:30}long_unsigned{224}long_unsigned{0}long_unsigned{0}long_unsigned{0}long_unsigned{0}long_unsigned{0}long_unsigned{0}double_long_unsigned{0}double_long_unsigned{0}double_long_unsigned{0}double_long_unsigned{0}long_unsigned{1000}}}
ending cycle Ciclo_instant_data_minute at 2024/11/29 11:23:36

It returns a dict:

from primestg.cycle.cycles import CycleFile

c = CycleFile(path='cicle.csv')

print(c.data)
[
    {
        "timestamp": "2024-11-29 11:23:36",
        "reg_name": "SAG0155349819",
        "operation": "get",
        "obis": "0.0.21.0.5.255",
        "class_id": 7,
        "element_id": 2,
        "data": [
            "2024/11/29 11:23:30",
            "224",
            "0",
            "0",
            "0",
            "0",
            "0",
            "0",
            "0",
            "0",
            "0",
            "0",
            "1000"
        ]
    }
]

Added cli primestg option parse_cycle for terminal use:

$ primestg parse_cycle spec/data/Ciclo_instant_data_minute_20241129_112335_0.csv 
[
    {
        "timestamp": "2024-11-29 11:23:36",
        "reg_name": "SAG0155349819",
        "operation": "get",
        "obis": "0.0.21.0.5.255",
        "class_id": 7,
        "element_id": 2,
        "data": [
            "2024/11/29 11:23:30",
            "224",
            "0",
            "0",
            "0",
            "0",
            "0",
            "0",
            "0",
            "0",
            "0",
            "0",
            "1000"
        ]
    }

@tinogis tinogis merged commit 46e1f5a into master Dec 9, 2024
0 of 2 checks passed
@tinogis tinogis deleted the NEW_cycle_csv_parser branch December 9, 2024 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants