The ascii_table command is used to format CSV into "ascii art" tables. These are useful for presentation and documentation. If you want to create XHTML tables, see the to_xml command.

See also: to_xml

Flag

Req'd?

Description

-h header

No

A comma-separated list of strings which will form the headers of the table. If the special string "@" is used, the headers are taken from the first row of the CSV input. If no headers are specified, the table is produced without headers.

-ra fields

No

A list of fields which will be right-aligned rather than the default left alignment. This is useful for numeric fields.

-s

No

Insert separator after each record.



The following example outputs the names.csv file, with suitable headers:

csvfix ascii_table -h "Forename,Surname,Sex" data/names.csv

which produces:

+----------+----------+-----+
| Forename | Surname  | Sex |
+----------+----------+-----+
| Charles  | Dickens  | M   |
| Jane     | Austen   | F   |
| Herman   | Melville | M   |
| Flann    | O'Brien  | M   |
| George   | Elliot   | F   |
| Virginia | Woolf    | F   |
| Oscar    | Wilde    | M   |
+----------+----------+-----+


You can insert a separator after each record using the -s option:


csvfix ascii_table -s -h "Forename,Surname,Sex" data/names.csv

produces:


+----------+----------+-----+

| Forename | Surname  | Sex |

+----------+----------+-----+

| Charles  | Dickens  | M   |

+----------+----------+-----+

| Jane     | Austen   | F   |

+----------+----------+-----+

| Herman   | Melville | M   |

+----------+----------+-----+

| Flann    | O'Brien  | M   |

+----------+----------+-----+

| George   | Elliot   | F   |

+----------+----------+-----+

| Virginia | Woolf    | F   |

+----------+----------+-----+

| Oscar    | Wilde    | M   |

+----------+----------+-----+


Created with the Personal Edition of HelpNDoc: Generate EPub eBooks with ease