On Sun, 2008-12-21 at 09:01 -0800, rob wrote:
> Is there a way, like a plugin or a perl/python tool, to draw ascii
> tables like below without having to painfully do it by hand? I'd like
> to be able to a) easily navigate between cells b) <left|right|top|
> bottom> justify text in cell c) edit cells and have the table
> readjust column width, table size??
>
> (to be viewed in fixed width font)
>
> +------------------------+------------+----------+----------+
> | Header row, column 1 | Header 2 | Header 3 | Header 4 |
> +------------------------+------------+----------+----------+
> | body row 1, column 1 | column 2 | column 3 | column 4 |
> | and more col 1 | | | and more |
> | and more | and more | and more | col4 |
> +------------------------+------------+----------+----------+
> | body row 2 | Cells may span column | |
> +------------------------+------------+----------+----------+
>
> Sounds like I'm being greedy and asking for too much, but I'm a sucker
> for these ascii tables and diagrams like the ones in RFC's. They just
> look beautiful.
>
> Any help is appreciated. I searched around quite a bit but didn't
> find any solutions..
I don't know about any Vim plugins, or scripting tools but many SQL
databases have interactive access tools that output the queries in ASCII
tables. All you have to do is load a table with your data.
Example:
mysql> SELECT * FROM sales;
+--------------+-------+--------+
| company | state | sales |
+--------------+-------+--------+
| ABC | AZ | 140.01 |
| XYZ | AZ | 17.76 |
| ABC | NY | 123.45 |
| XYZ | NY | 123.00 |
| Widgets Inc. | NY | 45.09 |
| ABC | NY | 23.73 |
| Widgets Inc. | CA | 97.30 |
+--------------+-------+--------+
7 rows in set (0.00 sec)
mysql> SELECT 'each' AS 'By', company AS Company, state AS State, LPAD(
SUM(sales), 9, ' ' ) AS Sales,
-> LPAD( FORMAT( SUM(sales)*100/(SELECT SUM(sales) FROM sales),2), 9, ' '
) AS Percent,
-> REPEAT( '*', SUM(sales)*50/(SELECT SUM(sales) FROM sales) )
-> AS Graph
-> FROM sales
-> GROUP BY company, state
-> UNION
-> SELECT ' company', company, '', LPAD( SUM(sales), 9, ' ' ),
-> LPAD( FORMAT( SUM(sales)*100/(SELECT SUM(sales) FROM sales),2), 9, ' '
),
-> REPEAT( '*', SUM(sales)*50/(SELECT SUM(sales) FROM sales) )
-> FROM sales
-> GROUP BY company
-> UNION
-> SELECT ' state', '', state, LPAD( SUM(sales), 9, ' ' ),
-> LPAD( FORMAT( SUM(sales)*100/(SELECT SUM(sales) FROM sales),2), 9, ' '
),
-> REPEAT( '*', SUM(sales)*50/(SELECT SUM(sales) FROM sales) )
-> FROM sales
-> GROUP BY state
-> UNION
-> SELECT ' -----', '-----', '-----', REPEAT( '-', 9 ), REPEAT( '-', 9 ),
REPEAT( ' ', 50 )
-> UNION
-> SELECT '-----', '-----', '-----', REPEAT( '-', 9 ), REPEAT( '-', 9 ),
REPEAT( ' ', 50 )
-> ORDER BY 1,2
-> ;
+-----------+--------------+-------+-----------+-----------+----------------------------------------------------+
| By | Company | State | Sales | Percent | Graph
|
+-----------+--------------+-------+-----------+-----------+----------------------------------------------------+
| company | ABC | | 287.19 | 50.35 |
************************* |
| company | Widgets Inc. | | 142.39 | 24.97 | ************
|
| company | XYZ | | 140.76 | 24.68 | ************
|
| ----- | ----- | ----- | --------- | --------- |
|
| state | | AZ | 157.77 | 27.66 | **************
|
| state | | CA | 97.30 | 17.06 | *********
|
| state | | NY | 315.27 | 55.28 |
**************************** |
| ----- | ----- | ----- | --------- | --------- |
|
| each | ABC | AZ | 140.01 | 24.55 | ************
|
| each | ABC | NY | 147.18 | 25.81 | *************
|
| each | Widgets Inc. | CA | 97.30 | 17.06 | *********
|
| each | Widgets Inc. | NY | 45.09 | 7.91 | ****
|
| each | XYZ | AZ | 17.76 | 3.11 | **
|
| each | XYZ | NY | 123.00 | 21.57 | ***********
|
+-----------+--------------+-------+-----------+-----------+----------------------------------------------------+
14 rows in set, 2 warnings (0.01 sec)
mysql>
--
Just my 0.00000002 million dollars worth,
Shawn
Believe in the Gods but row away from the rocks.
-- ancient Hindu proverb
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---