项目作者: reorx

项目描述 :
Draw ASCII art box with text.
高级语言: Python
项目地址: git://github.com/reorx/drawtable.git
创建时间: 2017-11-08T07:49:27Z
项目社区:https://github.com/reorx/drawtable

开源协议:

下载


Drawtable (csvless)

Build Status
Coverage Status

Drawtable is a python library for drawing ASCII table with text data.
It also contains a command line tool called csvless
that helps you view csv files without hassle.

Installation

  1. pip install drawtable

Usage

CLI tool

For details please see csvless -h, here are some typical examples:

  1. $ csvless samples/foo.csv
  2. $ csvless -s markdown samples/foo.csv
  3. $ csvless -s markdown --cat samples/foo.csv
  4. $ csvless -s box -N samples/foo.csv
  5. $ csvless -s box -N -n samples/foo.csv
  6. $ csvless -H samples/foo.csv
  7. $ csvless -w 10 --no-wrap samples/foo.csv

Library

Draw table box for list data:

  1. >>> from drawtable import Table
  2. >>> tb = Table(
  3. ... margin_x=1,
  4. ... margin_y=0,
  5. ... align='left',
  6. ... max_col_width=40,
  7. ... )
  8. >>> tb.draw([
  9. ... ['project', 'url'],
  10. ... ['drawtable', 'https://github.com/reorx/drawtable'],
  11. >>> ])
  12. ┌───────────┬────────────────────────────────────┐
  13. project url
  14. ├───────────┼────────────────────────────────────┤
  15. drawtable https://github.com/reorx/drawtable
  16. └───────────┴────────────────────────────────────┘

Draw a simple one cell box:

  1. >>> from drawtable import Table
  2. >>> tb = Table(
  3. ... margin_x=1,
  4. ... margin_y=0,
  5. ... align='center',
  6. ... max_col_width=40,
  7. ... )
  8. >>> tb.draw([[
  9. ... """Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."""
  10. ... ]])
  11. ┌──────────────────────────────────────────┐
  12. Lorem ipsum dolor sit amet, consectetur
  13. adipiscing elit, sed do eiusmod tempor i
  14. ncididunt ut labore et dolore magna aliq
  15. ua. Ut enim ad minim veniam, quis nostru
  16. d exercitation ullamco laboris nisi ut a
  17. liquip ex ea commodo consequat.
  18. └──────────────────────────────────────────┘