tabular 0.1.0-alpha copy "tabular: ^0.1.0-alpha" to clipboard
tabular: ^0.1.0-alpha copied to clipboard

outdated

Dart library for easily displaying tabular data in a visually appealing ASCII table format.

Tabular #

Dart library for easily displaying tabular data in a visually appealing ASCII table format.

Tabular is specifically designed to create tables in the Markdown format that GitHub understands.

The library is inspired by python's tabulate and pretty_table.


import 'package:tabular/tabular.dart';

var data = [
 ['Season', '#', 'Name', 'Days', 'Sun'],
 ['Winter', 1, 'January', 31, 94],
 ['Winter', 2, 'February', 28, 123],
 ['Spring', 3, 'March', 31, 42],
 ['Spring', 4, 'April', 30, 243],
 ['Spring', 5, 'May', 31, 5523],
 ['Summer', 6, 'June', 30, 11251],
 ['Summer', 7, 'July', 31, 17451],
 ['Summer', 8, 'August', 31, 18707],
 ['Autumn', 9, 'September', 30, 7025],
 ['Autumn', 10, 'October', 31, 5041],
 ['Autumn', 11, 'November', 30, 2302],
 ['Winter', 12, 'December', 31, 258],
];

var string = tabular(data);

print(string);
Season | # | Name | Days | Sun
-------|----|-----------|------|------
Winter | 1 | January | 31 | 94
Winter | 2 | February | 28 | 123
Spring | 3 | March | 31 | 42
Spring | 4 | April | 30 | 243
Spring | 5 | May | 31 | 5523
Summer | 6 | June | 30 | 11251
Summer | 7 | July | 31 | 17451
Summer | 8 | August | 31 | 18707
Autumn | 9 | September | 30 | 7025
Autumn | 10 | October | 31 | 5041
Autumn | 11 | November | 30 | 2302
Winter | 12 | December | 31 | 258

Formatting #

Add border #

tabular(data, outerBorder: true);
| Season | # | Name | Days | Sun |
|--------|----|-----------|------|-------|
| Winter | 1 | January | 31 | 94 |
| Winter | 2 | February | 28 | 123 |
| Spring | 3 | March | 31 | 42 |
| Spring | 4 | April | 30 | 243 |
| Spring | 5 | May | 31 | 5523 |
| Summer | 6 | June | 30 | 11251 |
| Summer | 7 | July | 31 | 17451 |
| Summer | 8 | August | 31 | 18707 |
| Autumn | 9 | September | 30 | 7025 |
| Autumn | 10 | October | 31 | 5041 |
| Autumn | 11 | November | 30 | 2302 |
| Winter | 12 | December | 31 | 258 |

Add markdown ':' alignment marks #

tabular(data, markdownAlign: true)
Season | # | Name | Days | Sun
-------|---:|-----------|-----:|-----:
Winter | 1 | January | 31 | 94
Winter | 2 | February | 28 | 123
Spring | 3 | March | 31 | 42
Spring | 4 | April | 30 | 243
Spring | 5 | May | 31 | 5523
Summer | 6 | June | 30 | 11251
Summer | 7 | July | 31 | 17451
Summer | 8 | August | 31 | 18707
Autumn | 9 | September | 30 | 7025
Autumn | 10 | October | 31 | 5041
Autumn | 11 | November | 30 | 2302
Winter | 12 | December | 31 | 258

Sorting #

Sort alphabetically by column 0 #

tabular(data, sort: [Sort(0)]) // 0 is 'Season'
Season | # | Name | Days | Sun
-------|----|-----------|------|------
Autumn | 9 | September | 30 | 7025
Autumn | 10 | October | 31 | 5041
Autumn | 11 | November | 30 | 2302
Spring | 3 | March | 31 | 42
Spring | 4 | April | 30 | 243
Spring | 5 | May | 31 | 5523
Summer | 6 | June | 30 | 11251
Summer | 7 | July | 31 | 17451
Summer | 8 | August | 31 | 18707
Winter | 1 | January | 31 | 94
Winter | 2 | February | 28 | 123
Winter | 12 | December | 31 | 258

Sort by 'Days' descending, and then by 'Sun' ascending #

tabular(data, sort: [Sort('Days', ascending: false), Sort('Sun')])
Season | # | Name | Days | Sun
-------|----|-----------|------|------
Spring | 3 | March | 31 | 42
Winter | 1 | January | 31 | 94
Winter | 12 | December | 31 | 258
Autumn | 10 | October | 31 | 5041
Spring | 5 | May | 31 | 5523
Summer | 7 | July | 31 | 17451
Summer | 8 | August | 31 | 18707
Spring | 4 | April | 30 | 243
Autumn | 11 | November | 30 | 2302
Autumn | 9 | September | 30 | 7025
Summer | 6 | June | 30 | 11251
Winter | 2 | February | 28 | 123
15
likes
0
pub points
74%
popularity

Publisher

verified publisherrevercode.com

Dart library for easily displaying tabular data in a visually appealing ASCII table format.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

quiver

More

Packages that depend on tabular