dimanche 30 mai 2021

Parse a .txt containing a custom data structure

I am trying to load the data present inside a .txt inside a structure. The problem is that the data inside the .txt does not respect a standard such as json, but is customized like this:

data1;
data2;
data3;
[
        {
            user_1,
            [
                {
                    a_1,
                    b_1,
                    c_1,
                    d_1
                },
                ..,
                {
                    a_n,
                    b_n,
                    c_n,
                    d_n
                }
            ]
        },
        ...,
        {
            user_n,
            [
                {
                    a_1,
                    b_1,
                    c_1,
                    d_1
                },
                ..,
                {
                    a_n,
                    b_n,
                    c_n,
                    d_n
                }
            ]
        }
];

I can't find a way to write code that can read inside arrays containing various 'users' with their 'a, b, c, d' data.

Unfortunately, I cannot modify the input data in any way, and furthermore, if characters or fields are missing, the type of error and its position must be precisely identified.

Finally, the file can be without any carriage returns and tabs, but in this case the data must still be read.

Could anyone give me an indication where I could figure out how to solve this problem? I have done various searches on the internet but I have not found anyone who tried to read a txt containing data structured in a personalized way.

Aucun commentaire:

Enregistrer un commentaire