Python Forum

Full Version: How do I write a line of code into an excel spreadsheet using Python code?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
My python code writing experience is scarcely a month and and I am now the proud parent of what has become a 500 line program written in python that process daily data so I can monitor my blood sugar. Results are presently written to a text file and it looks very 1980’s-ish. I want to create charts/graphs showing my trends and figure that Excel is a good way to do it.

I can now write the results to an excel file but only if I generate the entire output from all the data in the text file every time a new line of data is generated.

It would be far more efficient if I could append the daily line of data to the existing spreadsheet instead of rewriting it. As I see it, I would have to detect the last line written and go to the next row to place the new row of data.

Thoughts appreciated….
it depends on what package you use, but all of them have respective methods to write to specific cell/range
Python Excel The Definitive Guide
So there are serval ways,i like best Pandas in Jupyter notebook.
Dataframe look similar to Excel and can export to Excel,or drop Excel and do all in tool over
Common Excel Tasks Demonstrated in Pandas
Quote: I want to create charts/graphs showing my trends and figure that Excel is a good way to do it.
This is also something that tool i mention has very good support better than Excel.
Example Vis1, Vis2.