Comments (6)
These two utility methods are required
1. public static <T> List<String> getTableRows(Character[] borderChars, Collection<T> objects, List<ColumnData<T>> columns)
2. public static List<String> getTableRows(Character[] borderChars, Column[] rawColumns, Object[][] data)
from ascii-table.
Hi @freva , could you review my PR #11 ?
from ascii-table.
@sibiarunachalam Not sure how much utility these methods provide when you can achieve the same effect in 1 line by creating the table normally and then splitting the result by new line? E.g.:
String table = AsciiTable.getTable(planets, Arrays.asList(
new Column().with(planet -> Integer.toString(planet.num)),
new Column().header("Name").with(planet -> planet.name),
new Column().header("Diameter").with(planet -> String.format(Locale.US, "%.03f", planet.diameter)),
new Column().header("Mass").with(planet -> String.format(Locale.US, "%.02f", planet.mass)),
new Column().header("Atmosphere").maxColumnWidth(8).with(planet -> planet.atmosphere)));
List<String> rows = Stream.of(table.split(System.lineSeparator())).collect(Collectors.toList());
Or just Java 11:
List<String> rows = List.of(table.split(System.lineSeparator()));
from ascii-table.
Yes, @freva this workaround will solve the problem.
But, my points to have utility methods:
- In my case, I split the table into rows for some additional processing and merge them again as table. This util methods will remove these two steps (reverse processing) split and merge.
- Theses two steps are unnecessary overheads in Ascii Table construction especially when few hundred thousands of records involved
- It may cause problem when the data has line/row separator
- Other issue #9 need not be addressed immediately, but that would be nice to have feature.
- Library provides options to the developers (shouldn't enforce them to implement in one way that they consider as not good practice for many reasons)
- Even I am not sure about how much utility it provides, but ease of use.
Let say if we had those utility method, which approach would you prefer in my scenario?
from ascii-table.
Since ASCII tables is inherently for humans and not machines, I don't think/hope anyone would use this for anything more than a thousand rows, which makes any performance issue coming from the reverse processing negligible.
The library supports linebreaks in the data, feel free to try the split on this example: https://github.com/freva/ascii-table/blob/d19f522aaccd4a0e057f9843b7d722957c595559/src/test/java/com/github/freva/asciitable/AsciiTableTest.java#L320:L363
To make a utility method worthwhile, it should either solve a non-trivial problem or solve a frequent problem to the users. In my opinion, the solution/workaround is trivial, so it's not that. And I'm not convinced this is a frequent problem, how often would someone need to post-process something a table, specifically on row level? Maybe if this output all the cells, without borders, I could see it, because then the developers could actually customize a lot. With pure rows (including borders), all you can do is join it back together, or filter/insert some rows.
from ascii-table.
Okay @freva, thanks for your feedback.
from ascii-table.
Related Issues (16)
- Error in example maven dependency HOT 2
- Make it possible to cut column data instead of word wrapping when using maxColumnWidth HOT 5
- Allow to configure minColumnWidth HOT 1
- Is it posssible to set a preferred line separator? HOT 2
- Cut column in start instead of end HOT 2
- Make it easier to define table structure and afterwards to select which columns to print HOT 2
- Using colour output leads to table miss alignment HOT 9
- Adding a column that spans entire table as child to each row HOT 3
- Hyperlinks aren't rendered correclty HOT 2
- Ansi color glitch in adjacent cell HOT 7
- Column length ignores newlines HOT 1
- using AsciiTable as email body HOT 2
- Couldn't create a table from Collections HOT 2
- Can span columns be implemented? HOT 4
- Custom line/row separator HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ascii-table.