tomazbracic

tomazbracic

Which comtrade parser / parsing library do you recommend?

Hi,

I would like to ask for your opinion, find some suggestions on what to use (if there is any existing library I don’t know about), and how to approach it.

I am about to build a new product for parsing Comtrade .cfg and .dat files (there are two more files, but are not mandatory). COMTRADE (Common format for Transient Data Exchange for power systems) is a file format for storing oscillography and status data related to transient power system disturbances .

For better understanding, and if interested into the subject, you can take a look into this to get better understanding
http://dfv-technologie.com/doc_technique_dfv/perturbographie_qualimetrie/Tutorial%20COMTRADE.pdf

For others TLDR; you have .CFG files which describes a structure of .dat files. We’re talking about a mixture of ASCII and BINARY data and so on. Once you create a parser to understand the rules .cfg file define, you can go and parse binary data (.DAT) file. Each event has 1 .cfg and 1 .dat file. Later on I will need to do some correlations between 2 events and so on.

really simplified CFG example

EXAMPLE STATION NO. 1 DAU 32 N,32
15,7A,8D
1,161KV 01-G BUS POTENTIAL,kV, 0.479615,0.0,0.0,-511,511
2,161KV 02-G BUS POTENTIAL,kV, 0.479615,0.0,0.0,-511,511
3,161KV 03-G BUS POTENTIAL,kV, 0.479615,0.0,0.0,-511,511
4,161KV 01 CURRENT, A, 43.187479,0.0,0.0,-511,511
5,161KV 02 CURRENT, A, 43.187479,0.0,0.0,-511,511
6,161KV 03 CURRENT, A, 43.187479,0.0,0.0,-511,511
7,161KV RES CUR., A, 43.187479,0.0,0.0,-511,511
1,PCB 1216 EXAMPLE,1
2,PCB 1226 EXAMPLE,1
3,PCB 1236 EXAMPLE,1
4,161KV CAR. REC,1
5,161KV BUS POTENTIAL UV,1
6,161KV BUS POTENTIAL UF,1
7,EXTERNAL START,1
8,DATA CHECKSUM ERROR N/C,0
60
1
5184,47
01/18/1992,10: 2: 5.136
01/18/1992,10: 2: 5.215
ASCII
####################################################

really simplified DAT example

1,192,252,-233,-19,0,0,0,0,1,1,0,1,1,1,1,0
2,384,243,-243,0,0,0,0,0,1,1,0,1,1,1,1,0
3,576,232,-252,20,0,0,0,0,1,1,0,1,1,1,1,0
4,768,220,-260,40,0,0,0,0,1,1,0,1,1,1,1,0
5,960,207,-267,60,0,0,0,0,1,1,0,1,1,1,1,0
6,1152,192,-273,79,0,0,0,0,1,1,0,1,1,1,1,0
7,1344,176,-276,98,0,0,0,0,1,1,0,1,1,1,1,0
8,1536,160,-279,117,0,0,0,0,1,1,0,1,1,1,1,0
9,1728,142,-280,135,0,0,0,0,1,1,0,1,1,1,1,0
10,1920,124,-279,153,0,0,0,0,1,1,0,1,1,1,1,0
11,2112,105,-277,171,0,0,0,0,1,1,0,1,1,1,1,0
12,2304,85,-274,187,0,0,0,0,1,1,0,1,1,1,1,0
13,2496,65,-269,203,0,0,0,0,1,1,0,1,1,1,1,0
14,2688,45,-263,218,0,0,0,0,1,1,0,1,1,1,1,0
15,2880,25,-255,231,0,0,0,0,1,1,0,1,1,1,1,0
16,3072,5,-246,243,0,0,0,0,1,1,0,1,1,1,1,0
17,3264,-16,-235,253,0,0,0,0,1,1,0,1,1,1,1,0
18,3456,-36,-223,262,0,0,0,0,1,1,0,1,1,1,1,0
19,3648,-56,-210,269,0,0,0,0,1,1,0,1,1,1,1,0
20,3840,-76,-196,276,0,0,0,0,1,1,0,1,1,1,1,0
####################################################

This example above is ASCII type, mine are BINARY

Would you go and implement this on your own from the ground up or you would use some specific (existing) parsing library? I am asking if anybody knows of any library that might help me with parsing itself or if you don’t see this as an issue and would just write your own.

The other still “open” issue on this product is its integration into the Microsoft domain. I assume this shouldn’t be an issue anymore. MS LDAP and other keywords are probably well-supported by now. If you have any thoughts to share more than welcome.

Thanks for your opinion in advance.

First Post!

D4no0

D4no0

One question, is this a structured format or you need some kind of look-ahead to parse it?

If you don’t need look-ahead, you can easily use binary pattern matching to make a very simple declarative parser, I could help if the protocol is not huge.

Where Next?

Popular in Questions Top

aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
JulienCorb
I am trying to implement my new.html.eex file to create new posts on my website. new.html.eex: <h1>Create Post</h1> <%= ...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: The documentation above suggests that while ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call t...
New

Other popular topics Top

marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 39297 209
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 47930 226
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New

We're in Beta

About us Mission Statement