djeendo
djeendo

Reputation: 327

What data format is that? And how to parse it (python)?

Games from Valve use following data format

"name1"
{
    "name2"  "value2"
    "name3"
    {
        "name4" "value4"
    }
}

Does this format have a name or is it just self made?

Can I parse it in python?

Upvotes: 4

Views: 918

Answers (3)

Gjordis
Gjordis

Reputation: 2550

Looks a lot like JSON without comma and colon seperators. You could parse it manually since it has the same logic to it.

Seems to consist of name-value pairs, so after a name, finding a '{' or another string in "" would mean a value.

A composite structure of custom classes would make it easy to handle. As Matti John linked, there is documentation.

Upvotes: 0

asthasr
asthasr

Reputation: 9397

I'm not sure that it has a name, but it seems very straightforward: a node consists of a key and either a value or a set of values that are themselves either plain strings or sets of key-value pairs. It would be trivial to parse recursively, and maps cleanly to a structure of nested python dictionaries.

Upvotes: 1

Matti John
Matti John

Reputation: 20477

Looks like their own format, called Valve Data Format. Documentation here, I don't know if there is a parser available in python, but here is a question about parsing it in php

Upvotes: 0

Related Questions