Flat file database
Skip Montanaro
skip at pobox.com
Tue Dec 23 11:45:40 EST 2003
Art> Is there any Python module designed to simplify the use of a plain
Art> text file as a flat file database?
Several others have mentioned various possibilities. If Python
2.3 is available to you, you might consider the csv module. You can edit
the files with Excel or another spreadsheet. In your code, you can use the
csv.DictReader class to pull out the fields of interest:
# just off the top of my head!
def select(where, csvfile):
"return rows from csvfile which overlap with dictionary 'where'."
results = []
for row in csv.DictReader(csvfile):
if matches(where, row):
results.append(row)
return results
Coding of the matches function is left as an exercise for the reader. <wink>
Skip
More information about the Python-list
mailing list