| NiceFormatterTablizeTsv Method |
Converts an enumerable set of TSV (tab separated values) formatted lines into a mock table of rows and columns formatting using ASCII
box characters. Each input line is expected to contain the same number of tab separated values.
Namespace: Orthogonal.Common.BasicAssembly: Orthogonal.Common.Basic (in Orthogonal.Common.Basic.dll) Version: 2024-04-15 18:00 GMT+10.f27da1471008deaf16b803c17e24a5955690aef1
Syntax public static IEnumerable<string> TablizeTsv(
this IEnumerable<string> tabJoinedLines,
int? maxColLen = null,
int? maxRows = null
)
Parameters
- tabJoinedLines IEnumerableString
- An enumerable set of lines in TSV convention format.
- maxColLen NullableInt32 (Optional)
- Optional maximum length of text in each mock column.
- maxRows NullableInt32 (Optional)
- Optional maximum number of mock rows to process.
Return Value
IEnumerableStringAn enumerable set of text lines that display as a mock table using box ASCII characters.
Control characters in the displayed values are replaced with a small box U+25AB.
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type
IEnumerableString. When you use instance method syntax to call this method, omit the first parameter. For more information, see
Extension Methods (Visual Basic) or
Extension Methods (C# Programming Guide).
Example string[] tsv = new string[]
{
"Planet\tOrbit\tDiameter\tGravity",
"Mercury\t57.9\t4878\t0.38",
"Venus\t108.2\t12104\t0.9",
"Earth\t149.6\t12756\t1.0",
"Mars\t227.9\t6794\t0.38"
};
lines = NiceFormatter.TablizeTsv(tsv).ToArray();
foreach (var line in lines) Console.WriteLine(line);
┌─────────┬───────┬──────────┬─────────┐
│ Planet │ Orbit │ Diameter │ Gravity │
├─────────┼───────┼──────────┼─────────┤
│ Mercury │ 57.9 │ 4878 │ 0.38 │
│ Venus │ 108.2 │ 12104 │ 0.9 │
│ Earth │ 149.6 │ 12756 │ 1.0 │
│ Mars │ 227.9 │ 6794 │ 0.38 │
└─────────┴───────┴──────────┴─────────┘
See Also