 | NiceFormatter.TablizeTsv 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: 2025-03-15 14:42 GMT+11
Syntaxpublic static IEnumerable<string> TablizeTsv(
this IEnumerable<string> tabJoinedLines,
int? maxColLen = null,
int? maxRows = null
)
Parameters
- tabJoinedLines IEnumerable<String>
- An enumerable set of lines in TSV convention format.
- maxColLen Nullable<Int32> (Optional)
- Optional maximum length of text in each mock column.
- maxRows Nullable<Int32> (Optional)
- Optional maximum number of mock rows to process.
Return Value
IEnumerable<String>An 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
IEnumerable<String>. 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).
Examplestring[] 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