csvutils is a single Python module for easily transforming csv (or csv- like) generated rows. The release is available at http://pypi.python.org/pypi/csvutils/0.1.
Regards, George What is csvutils? ------------------------ The standard csv module is very useful for parsing tabular data in CSV format. Typically though, one or more transformations need to be applied to the generated rows before being ready to be used; for instance "convert the 3rd column to int, the 5th to float and ignore all the rest". csvutils provides an easy way to specify such transformations upfront instead of coding them every time by hand. Here are a few examples (more included as doctests): >>> import csv >>> from csvutils import SequenceTransformer >>> rows = list(csv.reader(["1,3.34,4-3.2j,John", ... "4,4,4,4", ... "0,-1.1,3.4,None"])) >>> # transform and return the first two columns only >>> for row in SequenceTransformer(int,float)(rows): ... print row [1, 3.3399999999999999] [4, 4.0] [0, -1.1000000000000001] >>> # transform the second column and leave the rest as is >>> for row in SequenceTransformer((1,float), default=None)(rows): ... print row ['1', 3.3399999999999999, '4-3.2j', 'John'] ['4', 4.0, '4', '4'] ['0', -1.1000000000000001, '3.4', 'None'] >>> # exclude the 4th column and eval() the rest (XXX: Use eval for trusted data only) >>> for row in SequenceTransformer(default=eval, exclude=[3]) (rows): ... print row [1, 3.3399999999999999, (4-3.2000000000000002j)] [4, 4, 4] [0, -1.1000000000000001, 3.3999999999999999] -- http://mail.python.org/mailman/listinfo/python-list