Function Kata "Tabulate CSV"


Write a function that tabulates CSV rows.

IEnumerable Tabulate(IEnumerable CSV_rows);

As input, the function receives an enumeration of strings. Each of these strings is a CSV line that could be sourced from a file, for example.

Example of a possible input:

Peter Pan; At the hillside 5; 12345 Lonely; 42
Maria Schmitz; Cologne street 45; 50123 Cologne; 43
Paul Meier; Munich way 1; 87654 Munich; 65

In the input data, a semicolon within the lines separates the individual values from each other. More complicated CSV mechanisms (for example, a semicolon in the data), do not need to be considered. The input data is always correctly structured, no error handling is required.

As output the function returns a formatted table of the input data. The first line of the input data is used as a header. The header is separated from the data by a separator line. The column width is based on the widest value in the data. The header is also taken into account.

Output for the example above:

Name         |Street           |City         |Age|
Peter Pan    |At the hillside 5|12345 Lonely |42 |
Maria Schmitz|Cologne Street 45|50123 Cologne|43 |
Paul Meier   |Munich Way 1     |87654 Munich |65 |