How to efficiently extract information from structured text file

Imaginationworks xiajunyi at gmail.com
Wed Feb 17 00:48:17 CET 2010


Hi,

I am trying to read object information from a text file (approx.
30,000 lines) with the following format, each line corresponds to a
line in the text file.  Currently, the whole file was read into a
string list using readlines(), then use for loop to search the "= {"
and "};" to determine the Object, SubObject,and SubSubObject. My
questions are

1) Is there any efficient method that I can search the whole string
list to find the location of the tokens(such as '= {' or '};'

2) Is there any efficient ways to extract the object information you
may suggest?

Thanks,

- Jeremy



===== Structured text file =================
Object1 = {

...

SubObject1 = {
....

SubSubObject1 = {
...
};
};

SubObject2 = {
....

SubSubObject21 = {
...
};
};

SubObjectN = {
....

SubSubObjectN = {
...
};
};
};



More information about the Python-list mailing list