scripts /

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# 2011-09-03

import csv
import sys
import yaml

def prepare_item(data):
    return data
#    return dict((k, v.decode('utf-8') if v and isinstance(v, str) else v)
#                for k, v in data.iteritems())

if __name__ == '__main__':
    path = sys.argv[1]
    with open(path) as f:
        reader = csv.DictReader(f)
        data = [prepare_item(d) for d in reader]

        # `default_flow_style = False` enforces more readable representation
        #     of lists and dictionaries.
        # `allow_unicode = True` allows unescaped non-ASCII sequences.
        print yaml.dump(data, default_flow_style=False, allow_unicode=True)