[Tutor] reading output from a c executable.
Steve Willoughby
steve at alchemy.com
Thu Dec 11 19:45:51 CET 2008
Ravi Kondamuru wrote:
> I am trying to read a binary log file to extract system counters. These
> counters will then be used to generate web-based graphs using the
> chart-director api in python. For extracting the counters I planning to
> write a program in C to read and give the output as lists for use by
> chart-director. If possible i would like to do the parsing of data only
> once in C on the log file and pass the processed output for direct use
> by python.
Wait..
Why not have Python read the binary log file itself, parse it and make
the API calls right there? Why do you even need the C program?
>
> I have thought about having to populate a database first but will prefer
> to avoid having another intermediate datastore (apart from the log file).
>
> thanks,
> Ravi.
>
> On Thu, Dec 11, 2008 at 10:27 AM, Steve Willoughby <steve at alchemy.com
> <mailto:steve at alchemy.com>> wrote:
>
> Ravi Kondamuru wrote:
>
> Hi,
> I am writing a script to read list output from a C executable.
> How should c program be written so that python can read the
> output as a list?
> Any pointers to info on this appreciated.
>
>
> The possibilities are truly wide open on this. Python can read a
> variety of standard formats (and of course can have custom code to
> read anything. Depending on what the data involved actually are,
> you need to decide what format works best.
>
> A simple approach is to have the C program write simple CSV output,
> and use Python's csv module to read it. A more complex solution
> might be to use XML. There are approximately 52,495,102 other
> possibilities available too, so you have lots of room to work out
> what's best for your application. More specific information on
> what you're trying to accomplish would help narrow it down as well.
>
>
More information about the Tutor
mailing list