Python Forum
How do I write a line of code into an excel spreadsheet using Python code?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do I write a line of code into an excel spreadsheet using Python code?
#1
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….
Reply
#2
it depends on what package you use, but all of them have respective methods to write to specific cell/range
Reply
#3
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Write from dictionary to excel divon 3 3,470 Jun-11-2023, 10:37 AM
Last Post: Larz60+
  problem of converting Matlab code to python DongyanZ 2 1,376 Feb-03-2023, 01:04 PM
Last Post: jefsummers
  Split excel file and write output at specific row and set sheet position DSCA 0 1,959 May-12-2022, 07:29 PM
Last Post: DSCA
  Reduce four for loops or parallelizing code in Python cee878 1 1,166 Feb-10-2022, 10:02 AM
Last Post: Larz60+
  [Pandas] Write data to Excel with dot decimals manonB 1 5,774 May-05-2021, 05:28 PM
Last Post: ibreeden
  Counting of rows in Excel Spreadsheet dakrantau 2 1,939 Sep-30-2020, 02:27 AM
Last Post: dakrantau
  How do I translate this into python code? (excel vlookup) eeps24 6 2,732 May-29-2020, 05:54 PM
Last Post: eeps24
  Python equivalent of Matlab code kwokmaster 5 6,995 Apr-03-2020, 12:02 AM
Last Post: scidam
  Read exel with merged cells and write to another excel SriMekala 0 2,938 Aug-10-2019, 07:14 AM
Last Post: SriMekala
  how read and write merged cells in excel SriMekala 1 15,061 Aug-07-2019, 11:27 PM
Last Post: scidam

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020