C#, 696 Bytes
Golfed:
string T(string[]f){int w=f.Max(r=>r.Length),a=f.Select(r=>r.Split(',')[0].Length).Max(),b=f.Select(r=>r.Split(',')[1].Length).Max(),c=f.Select(r=>r.Split(',')[2].Length).Max();string o="",n="\r\n",d="",j=string.Concat(Enumerable.Repeat("─",a)),k=string.Concat(Enumerable.Repeat("─",b)),l=string.Concat(Enumerable.Repeat("─",c));Func<string,int,string>z=(q,p)=>{return q.PadRight(p);};d="┌"+j+"┬"+k+"┬"+l+"┐";o+=d+n;var g=f.First().Split(',');o+="|"+z(g[0],a)+"|"+z(g[1],b)+"|"+z(g[2],c)+"|";d="├"+j+"┼"+k+"┼"+l+"┤";o+=n+d+n;for(int i=1;i<f.Length;i++){var h=f[i].Split(',');o+="|"+z(h[0],a)+"|"+z(h[1],b)+"|"+z(h[2],c)+"|"+n;}d="└"+j+"┴"+k+"┴"+l+"┘";o+=d;return o;}
Ungolfed (and nicer, because ^that is no use to anyone):
public string T(string[] c)
{
int width = c.Max(r => r.Length),
longestFirstColumn = c.Select(r => r.Split(',')[0].Length).Max(),
longestSecondColumn = c.Select(r => r.Split(',')[1].Length).Max(),
longestThirdColumn = c.Select(r => r.Split(',')[2].Length).Max();
string o = "", lr = "\r\n", border = "",
firstColumnFiller = string.Concat(Enumerable.Repeat("─", longestFirstColumn)),
secondColumnFiller = string.Concat(Enumerable.Repeat("─", longestSecondColumn)),
thirdColumnFiller = string.Concat(Enumerable.Repeat("─", longestThirdColumn));
Func<string, int, string> padRight = (a, b) => { return a.PadRight(b); };
border = "┌" + firstColumnFiller
+ "┬" +
secondColumnFiller + "┬"
+ thirdColumnFiller
+ "┐";
o += border + lr;
var firstRow = c.First().Split(',');
o += "|" + padRight(firstRow[0], longestFirstColumn) +
"|" + padRight(firstRow[1], longestSecondColumn) +
"|" + padRight(firstRow[2], longestThirdColumn) + "|";
border = "├" +
firstColumnFiller + "┼" +
secondColumnFiller + "┼" +
thirdColumnFiller
+ "┤";
o += lr + border + lr;
for (int i = 1; i < c.Length; i++)
{
var row = c[i].Split(',');
o += "|" + padRight(row[0], longestFirstColumn) + "|"
+ padRight(row[1], longestSecondColumn) + "|" +
padRight(row[2], longestThirdColumn) + "|" + lr;
}
border = "└" +
firstColumnFiller + "┴" +
secondColumnFiller + "┴" +
thirdColumnFiller
+ "┘";
o += border;
return o;
}
Testing:
┌──────┬───┬──────┐ ┌──────────┬───────────────────────────┬─────┐
|Name |Age|Gender| |Name |PPCG Challenge |Votes|
├──────┼───┼──────┤ ├──────────┼───────────────────────────┼─────┤
|Shaun |19 |Male | |Pete Arden| Print all integers | 4 |
|Debra |19 |Female| |Pete Arden| Yes of course I'm an adult| 3 |
|Alan |26 |Male | |Pete Arden| 5 Favorite Letters | 1 |
|George|15 |Male | └──────────┴───────────────────────────┴─────┘
└──────┴───┴──────┘
Can you explain the CSV format you expect, and/or limitations in input? CSV in itself is ambiguous as a format specification. – H Walters – 2016-11-21T13:16:58.137
What characters can appear in the CSV fields? – Martin Ender – 2016-11-21T13:18:58.127
2I think there are basically two ways you can go with the CSV definition. If the interesting part of the problem is the output, you can make it as simple as "split on commas" and not have to worry about how to quote commas and how to quote the quote character. Otherwise, you could state a specific method of parsing the CSV ("double quotes toggle a mode in which commas are ignored, two double quotes in a row produces a literal double quote" is a fairly common one, but by no means the only one in existence). – None – 2016-11-21T13:21:13.883
4Err, serious problem: you haven't specified a victory condition. What are the programs meant to be optimized for? Length ([tag:code-golf])? – None – 2016-11-21T13:23:16.167
Relevant information: 1, 2, 3, 4.
– Adám – 2016-11-21T14:00:43.8471At least the first three links there all define CSV differently (and at least two say that there are lots of different ways to do it). So I'm assuming that "CSV" needs to be more fully defined for use in a question (and that the solutions will try to get away with splitting on commas and not handling escaping because it allows them to be shorter). – None – 2016-11-21T14:26:38.737
2Okay I've edited the question to include specifics about the CSV format I would like everyone to use. – Shaun Wild – 2016-11-21T17:20:32.533
1CRLF? Seriously? That's going to give a fairly large penalty on Unix, where CR means something else in text files. You probably want to just replace that with "newline", allowing the OS-specific newline to be used. – None – 2016-11-21T23:29:20.203
Is input using list or array of strings (and no newlines) valid? – edc65 – 2016-11-29T08:19:21.053
@edc65 Nope.... – Shaun Wild – 2016-11-29T09:22:20.327
So APL and C# answers are invalid – edc65 – 2016-11-29T09:28:33.697
May the last input line have a newline like the other lines? – Adám – 2016-11-29T11:11:47.797
@Adám I will allow it. – Shaun Wild – 2016-11-29T11:13:20.077