ASV
Overview
ASV is a stable and mature platform independent Python module to input, manipulate and output `simple' database storage file formats such as CSV (Comma Separated Value) and TSV (Tab Separated Value). Building your own input/output routines is simple if you need to handle arbitrary file formats.
ASV features include:
- Extendable input / output scheme.
- Built in input routines possess `good enough' heuristics to parse even badly formed files.
- A command line interface for quick conversion between different formats.
- Built in format handlers for:
- Colon separated values.
- Comma Separated Values (CSV).
- Tab Separated Values (TSV).
Download
ASV is distributed under a BSD licence.
Versions available for download:
An example usage of the ASV module
# Import the ASV module
import ASV
# Create a blank ASV instance
my_data = ASV.ASV()
# We are loading from a file called "test_data.csv"
# We are using the CSV loader
# The CSV file we are loading has column headings so that we can access data
# by name rather than number
my_data.input_from_file("test_data.csv", ASV.CSV(), has_field_names = 1)
# Now `my_data' will hold some rows of data (presuming test_data.csv
# wasn't blank). You can use `my_data' just like a normal Python list
# Iterate over every row in my_data
for row in my_data:
# Print the row out - this gives us back an instance of the Row class
print row
# Print out a single element from the row
print row[1]
# Because our input file had field names, we can print out a named
# element in the row without having to know what its index is
print row["address"]
# Add a row to the end of `my_data'
my_data.append(["Laurie", "England"])
# Print out the row we just added
print my_data[-1]
# Save the data out as a TSV file
my_data.output_to_file("test_data_out.tsv", ASV.TSV())
History
- ASV 0.5 - 3 December 2002
- Fixed bug where giving a field with field_names to an ASV instance that didn't have field names itself caused problems.
- Fix ==/= typo in Row.__setitem__.
- ASV 0.4 - 3 April 2001
- Fixed bug where __setitem__ ignored the field_names parameter.
- Added switch to control whether "" in a field denotes a speech mark or not.
- Added code to make ASV `executable' with command line parameters etc.
- ASV 0.3 - 1 March 2001
First public release.
- ASV 0.2 - 2 November 2000
- ASV 0.1 - 29 October 2000
See also