hii..m stuck in an issue...and need a help

I have Try.c file having contents

ValidateFunction()
{
......
......
print
}
....

I want to print data between the braces {....}. Also i do not want to read the contents of file line by line because file is of very big size.How can I get this in Python?

You would have to read each record ("lines" is a word processing term and many types of files do not have lines) until you reach the first "{". Then store or print the records until the next "}". Then switch off an indicator. Note that you might want to count the number of "{"s and the number of "}"s to allow for multiple levels, and when they are equal set the indicator to False. To stop the file read would be something like this pseudo-code:

reading = True
while reading:
   fp.readline()
   if "}" is found or end_of_file:
       reading = False

Also the count of { can be used with itertools.groupby to divide the file in parts. Be careful about what you call very big size file. At least the file size should be in hundreds of megabytes to call it huge these days.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.