@@ -0,0 +1,951 @@
+from decimal import Decimal%0Aclass FixedWidthWriter():%0A%0A    def __init__(self, fd, fields):%0A        self.fd = fd%0A        self.fields = fields%0A%0A    def writerow(self, rowdict):%0A        _row = %5B%5D%0A        for field in self.fields:%0A            try:%0A                _key, _width, _options = field%0A            except ValueError:%0A                _key, _width = field%0A                _options = %7B%7D%0A            _value = rowdict%5B_key%5D%0A            _decimal_spaces = _options.get('decimal_spaces', 0)%0A            if _decimal_spaces:%0A                _value = unicode(Decimal(_value)%0A                                 .quantize(Decimal(10)**-_decimal_spaces))%0A            _part = '%7B0: %7B1%7D%7B2%7D%7D' %5C%0A                .format(_value, _options.get('direction', '%3C'), _width)%0A            _row.append(_part)%0A        _row = ''.join(_row)%0A        self.fd.write(_row + '%5Cn')%0A%0A    def writerows(self, rowdicts):%0A        for rowdict in rowdicts:%0A            self.writerow(rowdict)%0A

Create fixedwidth.py