- As you may know, I have been working on my "Refcards-System" for years now. I haven't made much progress, but I still have made some progress;
- This latest iteration is all about "writing" to a .csv file; the idea is that a .csv file can be "imported" into a relational database or else opened up as an "Excel" file, making it rather interoperable;
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import time | |
t = time.strftime('%Y%m%d%H%M') | |
with open(t+'.csv', 'wb') as csvfile: | |
writer = csv.writer(csvfile) | |
writer.writerow(['Time', 'Context', 'Notes', 'References']) | |
writer.writerow([time.asctime(), raw_input('Context: '), raw_input('Notes: '), raw_input('References: ')]) | |
csvfile.close() |
- Then basically I create the first "row" which are the "fieldnames" in the .csv file, and then I write the second "row" which is my content;
- Notice that I am using "raw_input", in Python that allows me to enter text directly into the file, with a prompt;
- The point is really to have content in .csv format, which is portable, interoperable, and lightweight as well. It's also a format that has withstood the test of time.