Home > Software e-mail: laurie@tratt.net   twitter: laurencetratt twitter: laurencetratt

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:

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

See also

Home > Software e-mail: laurie@tratt.net   twitter: laurencetratt twitter: laurencetratt