Home » excel » python – Creating excel chart from text file

python – Creating excel chart from text file

Posted by: admin March 9, 2020 Leave a comment

Questions:

I am running a simulation that saves some result in a file from which I take the data I need and save it in

result.dat

like so:

SAN.statisticsCollector.Network Response Time
Min: 0.210169
Max: 8781.55
average: 346.966666667

I do all this using python, and it was easy to convert result.dat into an excel file using xlwt. The problem is that creating charts using xlwt is not possible. I than came across Jpype, but installation on my ubuntu 12.04 machine was a headache. I’m probably just being lazy but still – is there any other way, not necessarily python-related, to convert result.dat into an excel file with charts?

Thanks

P.s the file I want to create is a spreadsheet, not Microsoft’s Excel!

How to&Answers:

The main problem is that currently there’s no Python library that implements MS Excel chart creation, and, obviously, they will not appear due to lack of good chart format documentation (as python-excel.org guys told) and its huge complecity.

There are two other options though:

  1. Another option is to use 3-rd party tools (like JPype that you’ve mentioned) combining them with Python scripts. As far as I know, except Java smartXML there’s no libraries that are capable of creating excel charts (or course, there are ones for .NET, e.g. expertXLS) and I’m not sure it will run on Mono + IronPython, though you can try.
  2. The third option is Win32 COM API, e.g. like described in this SO post, which is not quite an option for you due to your working operating system.

Answer:

there is a now a new possibility: http://pythonhosted.org/openpyxl/charts.html
and http://xlsxwriter.readthedocs.org/chart.html