| Home | laurie@tratt.net |
ASV is distributed under a BSD licence.
Versions available for download:
# 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())
| Home | Copyright © 2001 Laurence Tratt laurie@tratt.net |