How to Retain Excel Formula when running script on it
I just wrote a python script that takes an input csv, and outputs a new csv that has an extra column and does some stuff to the rows in the original file. Three of the columns in the input file had formulas, but it looks like the output file just takes the value that was in those columns, not the formula.
Is there a way to write my program such that the formula is written to the output, and not simply the value that is there?
When you convert your workbook to a CSV the formulas are not saved. Displayed values are saved in CSVs, not the formulas themselves.
If you want your formulas to be saved in the CSV, you will need have the cell show the formula itself instead of the value. You can do this by adding a ' to the beginning of the cell to indicate it should be treated as text.
In other words, this issue is caused before Python even starts reading your input CSV. The issue is created when you make the CSV.