0

Here is my data.

['date', 'x1', 'x2', 'x3', 'x4', 'x5']  
['2014-02-26', '302964.13', '11715.30', '1389.87', '404.63', '304354.00']  
['2014-02-25', '297672.69', '7406.57', '1733.45', '345.70', '299406.14']  
['2014-02-24', '297957.19', '9933.49', '1514.91', '345.56', '299472.10']  
['2014-02-21', '312826.51', '9365.13', '1308.66', '266.03', '314135.17']   
['2014-02-20', '325884.05', '10152.87', '1576.65', '483.17', '327460.70']  
['2014-02-19', '330013.56', '17205.76', '1729.29', '709.73', '331742.85']  
['2014-02-18', '327645.32', '11282.95', '1359.65', '190.63', '329004.96']  
['2014-02-17', '324224.52', '13298.12', '1080.77', '145.35', '325305.29']  
['2014-02-14', '324022.62', '11353.54', '1254.47', '183.25', '325277.08']  
['2014-02-13', '330918.46', '25570.06', '1597.78', '695.83', '332516.24']  
['2014-02-12', '324835.65', '10588.67', '1630.50', '456.97', '326466.15']  
['2014-02-11', '325785.09', '23822.77', '2214.77', '599.14', '327999.86']  
['2014-02-10', '319886.55', '12657.06', '1759.45', '169.27', '321646.00']  
['2014-02-07', '312989.44', '11284.82', '2225.87', '165.09', '315215.31']  
['2014-01-30', '305685.92', '3278.42', '1441.53', '65.08', '307127.45']  
['2014-01-29', '310027.36', '4866.76', '1211.53', '171.60', '311238.89']  
['2014-01-28', '311252.25', '5307.47', '1627.93', '110.17', '312880.19']  
['2014-01-27', '313464.93', '5316.03', '1579.17', '170.52', '315044.10']  
['2014-01-24', '315828.12', '9967.38', '1614.39', '222.52', '317442.51']

I want to wrap it into the form.

enter image description here

I can create the head and body

Head:

| date     |     x1   |  x2      |  x3    |    x4    |  x5        |

body:

|2014-02-27| 303664.88|   9753.48| 1455.21|    483.72|   305120.10|
|2014-02-26| 302964.13|  11715.30| 1389.87|    404.63|   304354.00|
|2014-02-25| 297672.69|   7406.57| 1733.45|    345.70|   299406.14|
|2014-02-24| 297957.19|   9933.49| 1514.91|    345.56|   299472.10|
|2014-02-21| 312826.51|   9365.13| 1308.66|    266.03|   314135.17|
|2014-02-20| 325884.05|  10152.87| 1576.65|    483.17|   327460.70|
|2014-02-19| 330013.56|  17205.76| 1729.29|    709.73|   331742.85|
|2014-02-18| 327645.32|  11282.95| 1359.65|    190.63|   329004.96|
|2014-02-17| 324224.52|  13298.12| 1080.77|    145.35|   325305.29|
|2014-02-14| 324022.62|  11353.54| 1254.47|    183.25|   325277.08|
|2014-02-13| 330918.46|  25570.06| 1597.78|    695.83|   332516.24|
|2014-02-12| 324835.65|  10588.67| 1630.50|    456.97|   326466.15|
|2014-02-11| 325785.09|  23822.77| 2214.77|    599.14|   327999.86|
|2014-02-10| 319886.55|  12657.06| 1759.45|    169.27|   321646.00|
|2014-02-07| 312989.44|  11284.82| 2225.87|    165.09|   315215.31|
|2014-01-30| 305685.92|   3278.42| 1441.53|     65.08|   307127.45|
|2014-01-29| 310027.36|   4866.76| 1211.53|    171.60|   311238.89|
|2014-01-28| 311252.25|   5307.47| 1627.93|    110.17|   312880.19|
|2014-01-27| 313464.93|   5316.03| 1579.17|    170.52|   315044.10|
|2014-01-24| 315828.12|   9967.38| 1614.39|    222.52|   317442.51|

how to create the first line in the table?

┌─────┬─────┬─────┬────┬─────┬──────┐

and the third line in the table?

├─────┼─────┼─────┼────┼─────┼──────┤

and the last line in the table?

└─────┴─────┴─────┴────┴─────┴──────┘

please write it in python.

the form is :

+------------+---------+-------------+
| column_one | col_two |   column_3  |
+------------+---------+-------------+
|          0 |  0.0001 | ABCD        |
|          1 |  1e-005 | ABCD        |
|          2 |  1e-006 | long string |
|          3 |  1e-007 | ABCD        |
+------------+---------+-------------+

not absolutely the same as mine posted here.

showkey
  • 482
  • 42
  • 140
  • 295
  • 1
    Related: http://stackoverflow.com/questions/9712085/numpy-pretty-print-tabular-data –  Mar 06 '14 at 06:49

1 Answers1

0

How obout taking the prettytable output (suggested in comment to your post) and just replacing the + chars with ones from your example? Pretty simple thing.

Mr. Girgitt
  • 2,853
  • 1
  • 19
  • 22