“If it ain’t broke, don’t fix it”.
This is the typical objection to moving from old-school spreadsheets to a more modern way of working with scripts.
To be clear, I am not opposed to the use of spreadsheets.
“Let’s not kid ourselves: the most widely used piece of software for statistics is Excel”
This quote (Brian Ripley) is over 20 years old now and still holds true. That said, the space filled by Excel is shrunk and shrinking. For good reasons. Excel should be used for what it’s good for, script should be used for what it’s good for.
No Tool should be used because your predecessor used it, but because it’s best for the job. Never cling to inertia out of laziness, or indeed, fear of the new. It’s my personal opinion that IT people, which are so detrimental to any business, are nothing more than professionals with an injected sense of “can do” attitude to be jealous of, and to learn from. We should all be drinking the same “can do” Kool-Aid.
Major strength (but of course also weakness) of Excel is that you can see everything as you go. No need to explicitly print to screen all the time. When you change a cell in the spread sheet you are sure that you change what you mean to change, and that it is undoubtedly changed; both of which are less easy in Rython. This said strength is something that you or your colleagues may want to keep. For instance for the sake of collaborating with less Rython-proficient team members. The next short video exemplify how you can do that. You can use the subprocess
module in to add a “browsing point” where you want to check or change your data in the way you have always done:
You are free to add as many of those “browsing points” as you regard necessary. The code used for the example is below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
import os import pandas as pd import subprocess def save_to_csv(data, filename): df = pd.DataFrame(data) df.to_csv(filename, index=False) def open_csv(filename): if os.name == 'nt': # Windows os.startfile(filename) elif os.name == 'posix': # macOS and Linux subprocess.run(['open', filename]) # Sample data data = { "Name": ["Alice", "Bob", "Charlie"], "Age": [25, 30, 22], "City": ["New York", "San Francisco", "Los Angeles"] } print(data) # os.getcwd() # Save the data to a CSV file csv_filename = "sample_data.csv" save_to_csv(data, csv_filename) # Open the CSV file with the default program open_csv(csv_filename) # Edit the CSV file externally # Load the modified CSV data back into Python using pandas modified_data = pd.read_csv(csv_filename) print(modified_data) |