Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/simon622/string-table

Java utility to allow quick rendering of tabulated data into various output formats
https://github.com/simon622/string-table

ascii csv database java logging table

Last synced: 28 days ago
JSON representation

Java utility to allow quick rendering of tabulated data into various output formats

Awesome Lists containing this project

README

        

# String-Table
Lightweight Java framework to allow quick rendering of tabulated data.
Great for debugging and quickly visualising data for logging or reporting.
Supports automatic column size detection, advanced sort, rollup and multiple output formats.

## Recent changes
* 2018 - Added support for ResultSet reading into StringTable
* 2019 - Added support for data sorting by Lexical and Numeric types.
* 2019 - Added support for HTML output

Inbuilt support for the following export formats;
* ASCII
* CSV
* HTML

## Simple example

```java
StringTable st = new StringTable("First Column", "Second Column", "Third Column");
for (int i = 0; i < 10; i++) {
st.addRow(i, i, i);
}
System.out.println(StringTableWriters.writeStringTableAsASCII(st));
```

## Database example

```java
ResultSet rs = ...
StringTable st = StringTableDatabaseUtils.readStringTable(rs);
System.out.println(StringTableWriters.writeStringTableAsHTML(st));
```

### Export as ASCII


+--------------++---------------++--------------+
| First Column || Second Column || Third Column |
+--------------++---------------++--------------+
| 0 || 0 || 0 |
| 1 || 1 || 1 |
| 2 || 2 || 2 |
| 3 || 3 || 3 |
| 4 || 4 || 4 |
| 5 || 5 || 5 |
| 6 || 6 || 6 |
| 7 || 7 || 7 |
| 8 || 8 || 8 |
| 9 || 9 || 9 |
+--------------++---------------++--------------+

### Export as HTML
First ColumnSecond ColumnThird Column000111222333444555666777888999

### Export as CSV
First Column,Second Column,Third Column
0,0,0
1,1,1
2,2,2
3,3,3
4,4,4
5,5,5
6,6,6
7,7,7
8,8,8
9,9,9

## Sort table
```java
StringTable st = new StringTable("First Column", "Second Column", "Third Column");
for (int i = 0; i < 10; i++) {
st.addRow(i, i, i);
}
st.sort(0, false);
```