0

Is there a simple way in Python (or other) to format nicely a file that looks like this :

Type    Count       Number
aaa 26 (-15)    5963206 
bbb 0 (0)    
ccc 347 (170)   4831807 4831907 
ddd 0 (0)    
eee 5 (2)   4831920 4831921 4831922 4831923 5695118 5757377 
fff 10 (10)  

I have 3 columns separated bu tabs (or space, or comma, or whatever) I would like an output similar to this :

+------------------------------------+
| Type  | Count    |  Number         |
+------------------------------------+
|aaa    | 26 (-15) | 5963206         |
|bbb    | 0 (0)    |                 |
|ccc    | 347 (170)| 4831807 4831907 |
|ddd    | 0 (0)    |                 |
|eee    | 5 (2)    | 4831920 4831921 |
|fff    | 10 (10)  |                 |
--------------------------------------
ecatmur
  • 152,476
  • 27
  • 293
  • 366
  • 2
    The answer in http://stackoverflow.com/questions/5909873/python-pretty-printing-ascii-tables might be helpful – ThiefMaster Aug 08 '12 at 12:39

1 Answers1

0

You could probably make use of Asciitable for this purpose. I think something like asciitable.FixedWidth would do with delimiter='|'

kojiro
  • 74,557
  • 19
  • 143
  • 201