csvlook

Parse CSV data from STDIN and beautify output.
Like csvlook from csvkit (https://github.com/onyxfish/csvkit/)

IN

a,b,c
1,2,3

OUT

|----+---+----|
|  a | b | c  |
|----+---+----|
|  1 | 2 | 3  |
|----+---+----|

IN

title,filename,url,retrieval_date
"Event Reports for Operating Reactors",event-notification-rpt-lastmonth.txt,"http://www.data.gov/download/4028",2011-04-17
"FY 09 Education Recipients by State.",FY09_EDU_Recipients_by_State.csv,http://www.data.gov/raw/4029,2011-04-17
"FY ""10"" Education Recipients by State",Datagov_FY10_EDU_recp_by_State.csv,http://www.data.gov/raw/4509,2011-04-17

OUT

|----------------------------------------+--------------------------------------+-----------------------------------+-----------------|
|  title                                 | filename                             | url                               | retrieval_date  |
|----------------------------------------+--------------------------------------+-----------------------------------+-----------------|
|  Event Reports for Operating Reactors  | event-notification-rpt-lastmonth.txt | http://www.data.gov/download/4028 | 2011-04-17      |
|  FY 09 Education Recipients by State.  | FY09_EDU_Recipients_by_State.csv     | http://www.data.gov/raw/4029      | 2011-04-17      |
|  FY "10" Education Recipients by State | Datagov_FY10_EDU_recp_by_State.csv   | http://www.data.gov/raw/4509      | 2011-04-17      |
|----------------------------------------+--------------------------------------+-----------------------------------+-----------------|

IN

text,date,integer,boolean,float,time,datetime,empty_column,_unnamed
Chicago Tribune,1920-01-01,164,False,41800000.01,00:00:00,1920-01-01T00:00:00,,
Chicago Sun-Times,1948-01-01,63,True,1.27,14:57:13,1948-01-01T14:57:13,,Extra data past headers will be trimmed
Chicago Reader,1971-01-01,40,True,1.0,04:14:00,1971-01-01T04:14:00,,
This row has blanks,,,,,,,,
Unicode!,,,,,,,,

OUT

|----------------------+------------+---------+---------+-------------+----------+---------------------+--------------+------------------------------------------|
|  text                | date       | integer | boolean | float       | time     | datetime            | empty_column | _unnamed                                 |
|----------------------+------------+---------+---------+-------------+----------+---------------------+--------------+------------------------------------------|
|  Chicago Tribune     | 1920-01-01 | 164     | False   | 41800000.01 | 00:00:00 | 1920-01-01T00:00:00 |              |                                          |
|  Chicago Sun-Times   | 1948-01-01 | 63      | True    | 1.27        | 14:57:13 | 1948-01-01T14:57:13 |              | Extra data past headers will be trimmed  |
|  Chicago Reader      | 1971-01-01 | 40      | True    | 1.0         | 04:14:00 | 1971-01-01T04:14:00 |              |                                          |
|  This row has blanks |            |         |         |             |          |                     |              |                                          |
|  Unicode!            |            |         |         |             |          |                     |              |                                          |
|----------------------+------------+---------+---------+-------------+----------+---------------------+--------------+------------------------------------------|

IN

a,b,c
1,2,3
4,,6
5,1,7

OUT

|----+---+----|
|  a | b | c  |
|----+---+----|
|  1 | 2 | 3  |
|  4 |   | 6  |
|  5 | 1 | 7  |
|----+---+----|
Login to submit solution


932 symbols php failed test 1 Wrong answer
$stdin = fopen('php://stdin', 'r');
$csv = array();
while (($arr = fgetcsv($stdin)) && $arr != array("") && $arr != array()) $csv[] = $arr;
$count = count($csv[0]);
$max = array();
for ($i = 0; $i < $count; $i++) $max[$i]=0;
for ($j = 0; $j < count($csv); $j++) {
    for ($i = 0; $i < $count; $i++) {
        $len = strlen($csv[$j][$i]);
        if ($max[$i] < $len) $max[$i] = $len;
    }
}
$new = array();
for ($i = 0; $i < $count; $i++) $new[$i] = str_repeat("-",$max[$i]+2);
$output = "|-".implode("+",$new)."-|";
$out1 = $output;
for ($i = 0; $i < $count; $i++) {
    $new[$i] = $csv[0][$i].str_repeat(" ",$max[$i]-strlen($csv[0][$i]));
}
$output .= "\n|  ".implode(" | ",$new)."  |\n".$out1."\n";
for ($j = 1; $j < count($csv); $j++) {
   for ($i = 0; $i < $count; $i++) $new[$i] = $csv[$j][$i].str_repeat(" ",$max[$i]-strlen($csv[$j][$i]));
   $output .= "|  ".implode(" | ",$new)."  |\n";
}
$output .= $out1;
echo $output;
instead of
|----+---+----|
|  a | b | c  |
|----+---+----|
|  1 | 2 | 3  |
|----+---+----|
Tue Jan 13 18:30:09 2015 dmitry-tiger
$stdin = fopen('php://stdin', 'r');
$csv = array();
while (($arr = fgetcsv($stdin)) && $arr != array("") && $arr != array()) $csv[] = $arr;
$count = count($csv[0]);
$max = array();
for ($i = 0; $i < $count; $i++) $max[$i]=0;
for ($j = 0; $j < count($csv); $j++) {
    for ($i = 0; $i < $count; $i++) {
        $len = strlen($csv[$j][$i]);
        if ($max[$i] < $len) $max[$i] = $len;
    }
}
$new = array();
for ($i = 0; $i < $count; $i++) $new[$i] = str_repeat("-",$max[$i]+2);
$output = "|-".implode("+",$new)."-|";
$out1 = $output;
for ($i = 0; $i < $count; $i++) {
    $new[$i] = $csv[0][$i].str_repeat(" ",$max[$i]-strlen($csv[0][$i]));
}
$output .= "\n|  ".implode(" | ",$new)."  |\n".$out1."\n";
for ($j = 1; $j < count($csv); $j++) {
   for ($i = 0; $i < $count; $i++) $new[$i] = $csv[$j][$i].str_repeat(" ",$max[$i]-strlen($csv[$j][$i]));
   $output .= "|  ".implode(" | ",$new)."  |\n";
}
$output .= $out1;
echo $output;
698 symbols php failed test 1 Wrong answer
<?mb_internal_encoding("UTF-8");$f=fopen('php://stdin','r');$c=array();while(($a=fgetcsv($f))&&$a!=array("")&&$a!=array())$c[]=$a;$d=count($c[0]);$m=array();$n=$m;for($i=0;$i<$d;$i++)$m[$i]=0;$y=count($c);for($j=0;$j<$y;$j++){for($i=0;$i<$d; $i++){$x=strlen(utf8_decode($c[$j][$i]));if($m[$i]<$x)$m[$i]=$x;}}for($i=0;$i<$d;$i++)$n[$i]=str_repeat("-",$m[$i]+2);$l="|-".implode("+",$n)."-|";$z=$l;for($i=0;$i<$d;$i++)$n[$i]=$c[0][$i].str_repeat(" ",$m[$i]-strlen(utf8_decode($c[0][$i])));$l.="\n|  ".implode(" | ",$n)."  |\n".$z."\n";for($j=1;$j<$y;$j++){for($i=0;$i<$d;$i++)$n[$i]=$c[$j][$i].str_repeat(" ",$m[$i]-strlen(utf8_decode($c[$j][$i])));$l.="|  ".implode(" | ",$n)."  |\n";}$l.=$z;echo $l;
instead of
|----+---+----|
|  a | b | c  |
|----+---+----|
|  1 | 2 | 3  |
|----+---+----|
Tue Jan 13 19:11:31 2015 AndreyM
<?mb_internal_encoding("UTF-8");$f=fopen('php://stdin','r');$c=array();while(($a=fgetcsv($f))&&$a!=array("")&&$a!=array())$c[]=$a;$d=count($c[0]);$m=array();$n=$m;for($i=0;$i<$d;$i++)$m[$i]=0;$y=count($c);for($j=0;$j<$y;$j++){for($i=0;$i<$d; $i++){$x=strlen(utf8_decode($c[$j][$i]));if($m[$i]<$x)$m[$i]=$x;}}for($i=0;$i<$d;$i++)$n[$i]=str_repeat("-",$m[$i]+2);$l="|-".implode("+",$n)."-|";$z=$l;for($i=0;$i<$d;$i++)$n[$i]=$c[0][$i].str_repeat(" ",$m[$i]-strlen(utf8_decode($c[0][$i])));$l.="\n|  ".implode(" | ",$n)."  |\n".$z."\n";for($j=1;$j<$y;$j++){for($i=0;$i<$d;$i++)$n[$i]=$c[$j][$i].str_repeat(" ",$m[$i]-strlen(utf8_decode($c[$j][$i])));$l.="|  ".implode(" | ",$n)."  |\n";}$l.=$z;echo $l;
461 symbols php failed test 1 Wrong answer
<?eval(gzinflate(base64_decode("lVBNj4IwEP0rTTOHEhZ092S29rq/YPekhLClaA0UUuoGFP/7TgWNMcbESwMz7837qH5TbZyyJitTZWSda7Nh9Of7K1rQgEMhCl0qRptt8zmbtQ7XfixFZm3Ws4AXtVWZ3DIoSNYSaAOQq0S0zqYb5WT7x5zVFcM5snIh671xDCHzBP+r6xUwAip/i4EWcw56CTm+YRhAtQKd+Fl/ZQcjcuenuyX0+CLyeEcnZ/4ROu+mVIbtXbFIc4UZlbcAu8SfRmO6YKPMErqLIHT8dHpoyJz3PqFVjcocoxF9G1nhB0YpBR0iGuuqKb0SDXFrgphGA+VwEFA+zjmePVfjv+JbAXIRiB5HmU9JvHos6NoMhNw4IAOZPBAyrA2N4RAjiF5qfH9W4527qbWX7F2bnvw9d8dPHgQHruS2JljXPw==")));
instead of
|----+---+----|
|  a | b | c  |
|----+---+----|
|  1 | 2 | 3  |
|----+---+----|
Tue Jan 13 20:08:54 2015 AndreyM
<?eval(gzinflate(base64_decode("lVBNj4IwEP0rTTOHEhZ092S29rq/YPekhLClaA0UUuoGFP/7TgWNMcbESwMz7837qH5TbZyyJitTZWSda7Nh9Of7K1rQgEMhCl0qRptt8zmbtQ7XfixFZm3Ws4AXtVWZ3DIoSNYSaAOQq0S0zqYb5WT7x5zVFcM5snIh671xDCHzBP+r6xUwAip/i4EWcw56CTm+YRhAtQKd+Fl/ZQcjcuenuyX0+CLyeEcnZ/4ROu+mVIbtXbFIc4UZlbcAu8SfRmO6YKPMErqLIHT8dHpoyJz3PqFVjcocoxF9G1nhB0YpBR0iGuuqKb0SDXFrgphGA+VwEFA+zjmePVfjv+JbAXIRiB5HmU9JvHos6NoMhNw4IAOZPBAyrA2N4RAjiF5qfH9W4527qbWX7F2bnvw9d8dPHgQHruS2JljXPw==")));
474 symbols perl failed test 1 Wrong answer
+----+---+----+
|  a | b | c  |
+----+---+----+
|  1 | 2 | 3  |
+----+---+----+
instead of
|----+---+----|
|  a | b | c  |
|----+---+----|
|  1 | 2 | 3  |
|----+---+----|
Tue Jan 13 21:14:06 2015 dmitry-tiger
while (<>){
    s/[\r\n]//g;
    s/,(?=,)/, /g;
    my @F=split(",",$_);
    $#F=$#m if $#F<$#m;
    push @H,\@F;
           no bytes;
    @c=map{length}@F;
           use bytes;
    for ($i=0;$i<=$#c;$i++){
       $m[$i] = $c[$i] if $m[$i] < $c[$i]
    }
}
sub p{
    print '+-'.join ('+',(map{"-"x($_+2)} @m))."-+\n";
}
p;
for $f (@H){
        $j=-1;
        p if $d++==1;
 
        @a=map{$j++;sprintf"%-$m[$j]s",$_}@$f;
        print "|  ".join(" | ",@a)."  |\n";
}
p();
474 symbols perl failed test 2 Wrong answer
|--------------------------------------------+--------------------------------------+-------------------------------------+-----------------|
|  title                                     | filename                             | url                                 | retrieval_date  |
|--------------------------------------------+--------------------------------------+-------------------------------------+-----------------|
|  "Event Reports for Operating Reactors"    | event-notification-rpt-lastmonth.txt | "http://www.data.gov/download/4028" | 2011-04-17      |
|  "FY 09 Education Recipients by State."    | FY09_EDU_Recipients_by_State.csv     | http://www.data.gov/raw/4029        | 2011-04-17      |
|  "FY ""10"" Education Recipients by State" | Datagov_FY10_EDU_recp_by_State.csv   | http://www.data.gov/raw/4509        | 2011-04-17      |
|--------------------------------------------+--------------------------------------+-------------------------------------+-----------------|
instead of
|----------------------------------------+--------------------------------------+-----------------------------------+-----------------|
|  title                                 | filename                             | url                               | retrieval_date  |
|----------------------------------------+--------------------------------------+-----------------------------------+-----------------|
|  Event Reports for Operating Reactors  | event-notification-rpt-lastmonth.txt | http://www.data.gov/download/4028 | 2011-04-17      |
|  FY 09 Education Recipients by State.  | FY09_EDU_Recipients_by_State.csv     | http://www.data.gov/raw/4029      | 2011-04-17      |
|  FY "10" Education Recipients by State | Datagov_FY10_EDU_recp_by_State.csv   | http://www.data.gov/raw/4509      | 2011-04-17      |
|----------------------------------------+--------------------------------------+-----------------------------------+-----------------|
Tue Jan 13 21:18:04 2015 dmitry-tiger
while (<>){
    s/[\r\n]//g;
    s/,(?=,)/, /g;
    my @F=split(",",$_);
    $#F=$#m if $#F<$#m;
    push @H,\@F;
           no bytes;
    @c=map{length}@F;
           use bytes;
    for ($i=0;$i<=$#c;$i++){
       $m[$i] = $c[$i] if $m[$i] < $c[$i]
    }
}
sub p{
    print '|-'.join ('+',(map{"-"x($_+2)} @m))."-|\n";
}
p;
for $f (@H){
        $j=-1;
        p if $d++==1;
 
        @a=map{$j++;sprintf"%-$m[$j]s",$_}@$f;
        print "|  ".join(" | ",@a)."  |\n";
}
p();
380 symbols perl failed test 2 Wrong answer
|------------------------------------------+--------------------------------------+-------------------------------------+-----------------|
|  title                                   | filename                             | url                                 | retrieval_date  |
|------------------------------------------+--------------------------------------+-------------------------------------+-----------------|
|  Event Reports for Operating Reactors    | event-notification-rpt-lastmonth.txt | http://www.data.gov/download/4028   | 2011-04-17      |
|  FY 09 Education Recipients by State.    | FY09_EDU_Recipients_by_State.csv     | http://www.data.gov/raw/4029        | 2011-04-17      |
|  FY "10" Education Recipients by State   | Datagov_FY10_EDU_recp_by_State.csv   | http://www.data.gov/raw/4509        | 2011-04-17      |
|------------------------------------------+--------------------------------------+-------------------------------------+-----------------|
instead of
|----------------------------------------+--------------------------------------+-----------------------------------+-----------------|
|  title                                 | filename                             | url                               | retrieval_date  |
|----------------------------------------+--------------------------------------+-----------------------------------+-----------------|
|  Event Reports for Operating Reactors  | event-notification-rpt-lastmonth.txt | http://www.data.gov/download/4028 | 2011-04-17      |
|  FY 09 Education Recipients by State.  | FY09_EDU_Recipients_by_State.csv     | http://www.data.gov/raw/4029      | 2011-04-17      |
|  FY "10" Education Recipients by State | Datagov_FY10_EDU_recp_by_State.csv   | http://www.data.gov/raw/4509      | 2011-04-17      |
|----------------------------------------+--------------------------------------+-----------------------------------+-----------------|
Tue Jan 13 22:20:13 2015 dmitry-tiger
while (<>){s/[\r\n]//g;s/,(?=,)/, /g;s/""/"/g;my @F=split(",",$_);$#F=$#m if $#F<$#m;push @H,\@F;@c=map{length}@F;for ($i=0;$i<=$#c;$i++){$m[$i]=$c[$i] if $m[$i]<$c[$i]}}
sub p{print '|-'.join('+',(map{"-"x($_+2)} @m))."-|\n";}p;
for $f(@H){$j=-1;p if $d++==1;use Encode;print "|  ".join(" | ",map{$j++;$b=$_;$b=~s/^"|"$//g;$b=decode_utf8($b); sprintf"%-$m[$j]s",$b}@$f)."  |\n"}p
356 symbols perl failed test 1 Wrong answer
|----+---+----|
|  1 | 1 | 1  |
|----+---+----|
|  1 | 1 | 1  |
|----+---+----|
instead of
|----+---+----|
|  a | b | c  |
|----+---+----|
|  1 | 2 | 3  |
|----+---+----|
Tue Jan 13 22:50:29 2015 avkhozov
while(<>){s/[\r\n]//g;s/,(?=,)/, /g;s/(?<!")"(?!")//g;s/""/"/g;my @F=split(",",$_);$#F=$#m if$#F<$#m;push@H,\@F;@c=map{length}@F;for($i=0;$i<=$#c;$i++){$m[$i]=$c[$i]if$m[$i]<$c[$i]}}sub p{print '|-'.join ('+',(map{"-"x($_+2)} @m))."-|\n"}p;for$f(@H){$j=-1;p if$d++==1;@a=map{$j++;sprintf"%-$m[$j]s",utf8::decode($_)}@$f;print"|  ".join(" | ",@a)."  |\n"}p;
359 symbols perl failed test 2 Wrong answer
|----------------------------------------+--------------------------------------+-----------------------------------+-----------------|
|  title | filename | url | retrieval_date  |
|----------------------------------------+--------------------------------------+-----------------------------------+-----------------|
|  Event Reports for Operating Reactors | event-notification-rpt-lastmonth.txt | http://www.data.gov/download/4028 | 2011-04-17  |
|  FY 09 Education Recipients by State. | FY09_EDU_Recipients_by_State.csv | http://www.data.gov/raw/4029 | 2011-04-17  |
|  FY "10" Education Recipients by State | Datagov_FY10_EDU_recp_by_State.csv | http://www.data.gov/raw/4509 | 2011-04-17  |
|----------------------------------------+--------------------------------------+-----------------------------------+-----------------|
instead of
|----------------------------------------+--------------------------------------+-----------------------------------+-----------------|
|  title                                 | filename                             | url                               | retrieval_date  |
|----------------------------------------+--------------------------------------+-----------------------------------+-----------------|
|  Event Reports for Operating Reactors  | event-notification-rpt-lastmonth.txt | http://www.data.gov/download/4028 | 2011-04-17      |
|  FY 09 Education Recipients by State.  | FY09_EDU_Recipients_by_State.csv     | http://www.data.gov/raw/4029      | 2011-04-17      |
|  FY "10" Education Recipients by State | Datagov_FY10_EDU_recp_by_State.csv   | http://www.data.gov/raw/4509      | 2011-04-17      |
|----------------------------------------+--------------------------------------+-----------------------------------+-----------------|
Tue Jan 13 22:51:27 2015 avkhozov
while(<>){s/[\r\n]//g;s/,(?=,)/, /g;s/(?<!")"(?!")//g;s/""/"/g;my @F=split(",",$_);$#F=$#m if$#F<$#m;push@H,\@F;@c=map{length}@F;for($i=0;$i<=$#c;$i++){$m[$i]=$c[$i]if$m[$i]<$c[$i]}}sub p{print '|-'.join ('+',(map{"-"x($_+2)} @m))."-|\n"}p;for$f(@H){$j=-1;p if$d++==1;@a=map{$j++;sprintf"%-$m[$j]s",utf8::decode($_);$_}@$f;print"|  ".join(" | ",@a)."  |\n"}p;
359 symbols perl failed test 2 Wrong answer
|----------------------------------------+--------------------------------------+-----------------------------------+-----------------|
|  title | filename | url | retrieval_date  |
|----------------------------------------+--------------------------------------+-----------------------------------+-----------------|
|  Event Reports for Operating Reactors | event-notification-rpt-lastmonth.txt | http://www.data.gov/download/4028 | 2011-04-17  |
|  FY 09 Education Recipients by State. | FY09_EDU_Recipients_by_State.csv | http://www.data.gov/raw/4029 | 2011-04-17  |
|  FY "10" Education Recipients by State | Datagov_FY10_EDU_recp_by_State.csv | http://www.data.gov/raw/4509 | 2011-04-17  |
|----------------------------------------+--------------------------------------+-----------------------------------+-----------------|
instead of
|----------------------------------------+--------------------------------------+-----------------------------------+-----------------|
|  title                                 | filename                             | url                               | retrieval_date  |
|----------------------------------------+--------------------------------------+-----------------------------------+-----------------|
|  Event Reports for Operating Reactors  | event-notification-rpt-lastmonth.txt | http://www.data.gov/download/4028 | 2011-04-17      |
|  FY 09 Education Recipients by State.  | FY09_EDU_Recipients_by_State.csv     | http://www.data.gov/raw/4029      | 2011-04-17      |
|  FY "10" Education Recipients by State | Datagov_FY10_EDU_recp_by_State.csv   | http://www.data.gov/raw/4509      | 2011-04-17      |
|----------------------------------------+--------------------------------------+-----------------------------------+-----------------|
Tue Jan 13 22:57:45 2015 avkhozov
while(<>){s/[\r\n]//g;s/,(?=,)/, /g;s/(?<!")"(?!")//g;s/""/"/g;my @F=split(",",$_);$#F=$#m if$#F<$#m;push@H,\@F;@c=map{length}@F;for($i=0;$i<=$#c;$i++){$m[$i]=$c[$i]if$m[$i]<$c[$i]}}sub p{print '|-'.join ('+',(map{"-"x($_+2)} @m))."-|\n"}p;for$f(@H){$j=-1;p if$d++==1;@a=map{$j++;sprintf"%-$m[$j]s",utf8::decode($_);$_}@$f;print"|  ".join(" | ",@a)."  |\n"}p;
339 symbols perl failed test 1 Wrong answer
|----+---+----+
|  a | b | c  |
|----+---+----+
|  1 | 2 | 3  |
|----+---+----+
instead of
|----+---+----|
|  a | b | c  |
|----+---+----|
|  1 | 2 | 3  |
|----+---+----|
Wed Jan 14 03:48:31 2015 g0ga
binmode($_,':utf8')for(STDIN,STDOUT);while(<>){my@r;s/"+/"/g;push@r,$3 while/(^|,)("*)(.*?)\2(?=,|$)/g;push@t,\@r if@r;$i=0;do{$l=2+length;$c[$i]=$l if$l> $c[$i];++$i}for@r}sub p{$r=@_?'| ':'|-';$j=0;for(@c){$r.=@_?" $_[$j]@{[' 'x($_-1-length$_[$j])]}|":'-'x$_.'+';++$j}$r=~s/(.)(?=.$)/$1$1/;print$r,"\n"}&p;p(@{shift@t});&p;p(@$_)for@t;&p
354 symbols perl failed test 1 Wrong answer
|----+---+----+
|  a | b | c  |
|----+---+----+
|  1 | 2 | 3  |
|----+---+----+
instead of
|----+---+----|
|  a | b | c  |
|----+---+----|
|  1 | 2 | 3  |
|----+---+----|
Wed Jan 14 03:58:30 2015 g0ga
binmode($_,':utf8')for(STDIN,STDOUT);while(<>){chomp;$_||next;my@r;s/"+/"/g;push@r,$3 while/(^|,)("*)(.*?)\2(?=,|$)/g;push@t,\@r if@r;$i=0;do{$l=2+length;$c[$i]=$l if$l> $c[$i];++$i}for@r}sub p{$r=@_?'| ':'|-';$j=0;for(@c){$r.=@_?" $_[$j]@{[' 'x($_-1-length$_[$j])]}|":'-'x$_.'+';++$j}$r=~s/(.)(?=.$)/$1$1/;print$r,"\n"}&p;p(@{shift@t});&p;p(@$_)for@t;&p
292 symbols perl failed test 1 Code error

syntax error at ./code line 1, near "$g)" syntax error at ./code line 1, near "$S}" Execution of ./code aborted due to compilation errors.

Tue Jan 20 12:35:36 2015 vakorol
binmode STDIN,':utf8';$j=0,@{$a[$i++]}=map{s/\n//;$m[$j-1]=$l if($l=length)>$m[$j++];$_}split/,/,$_ while<>;$t,$s,$g)=$y&&$y!=2&&$y<@a+2?(' ','','|'):qw/- - +/,$k=0,print("|$t".(join$g,map{($S=$s x$m[$k])||=$_;sprintf"$t%-$m[$k++]s$t",$S}@$_)."$t|\n"),++$y>@a+2?last:$s||$y==@a+2)&&redo for@a
294 symbols perl failed test 2 Wrong answer
|--------------------------------------------+--------------------------------------+-------------------------------------+-----------------|
|  title                                     | filename                             | url                                 | retrieval_date  |
|--------------------------------------------+--------------------------------------+-------------------------------------+-----------------|
|  "Event Reports for Operating Reactors"    | event-notification-rpt-lastmonth.txt | "http://www.data.gov/download/4028" | 2011-04-17      |
|  "FY 09 Education Recipients by State."    | FY09_EDU_Recipients_by_State.csv     | http://www.data.gov/raw/4029        | 2011-04-17      |
|  "FY ""10"" Education Recipients by State" | Datagov_FY10_EDU_recp_by_State.csv   | http://www.data.gov/raw/4509        | 2011-04-17      |
|--------------------------------------------+--------------------------------------+-------------------------------------+-----------------|
instead of
|----------------------------------------+--------------------------------------+-----------------------------------+-----------------|
|  title                                 | filename                             | url                               | retrieval_date  |
|----------------------------------------+--------------------------------------+-----------------------------------+-----------------|
|  Event Reports for Operating Reactors  | event-notification-rpt-lastmonth.txt | http://www.data.gov/download/4028 | 2011-04-17      |
|  FY 09 Education Recipients by State.  | FY09_EDU_Recipients_by_State.csv     | http://www.data.gov/raw/4029      | 2011-04-17      |
|  FY "10" Education Recipients by State | Datagov_FY10_EDU_recp_by_State.csv   | http://www.data.gov/raw/4509      | 2011-04-17      |
|----------------------------------------+--------------------------------------+-----------------------------------+-----------------|
Tue Jan 20 12:37:01 2015 vakorol
binmode STDIN,':utf8';$j=0,@{$a[$i++]}=map{s/\n//;$m[$j-1]=$l if($l=length)>$m[$j++];$_}split/,/,$_ while<>;($t,$s,$g)=$y&&$y!=2&&$y<@a+2?(' ','','|'):qw/- - +/,$k=0,print("|$t".(join$g,map{($S=$s x$m[$k])||=$_;sprintf"$t%-$m[$k++]s$t",$S}@$_)."$t|\n"),++$y>@a+2?last:($s||$y==@a+2)&&redo for@a
310 symbols perl failed test 3 Wrong answer
|----------------------+------------+---------+---------+-------------+----------+---------------------+--------------+------------------------------------------|
|  text                | date       | integer | boolean | float       | time     | datetime            | empty_column | _unnamed                                 |
|----------------------+------------+---------+---------+-------------+----------+---------------------+--------------+------------------------------------------|
|  Chicago Tribune     | 1920-01-01 | 164     | False   | 41800000.01 | 00:00:00 | 1920-01-01T00:00:00 |              |                                          |
|  Chicago Sun-Times   | 1948-01-01 | 63      | True    | 1.27        | 14:57:13 | 1948-01-01T14:57:13 |              | Extra data past headers will be trimmed  |
|  Chicago Reader      | 1971-01-01 | 40      | True    | 1.0         | 04:14:00 | 1971-01-01T04:14:00 |              |                                          |
|  This row has blanks |            |         |         |             |          |                     |              |                                          |
|  Unicode!             |
|-----------------------|
instead of
|----------------------+------------+---------+---------+-------------+----------+---------------------+--------------+------------------------------------------|
|  text                | date       | integer | boolean | float       | time     | datetime            | empty_column | _unnamed                                 |
|----------------------+------------+---------+---------+-------------+----------+---------------------+--------------+------------------------------------------|
|  Chicago Tribune     | 1920-01-01 | 164     | False   | 41800000.01 | 00:00:00 | 1920-01-01T00:00:00 |              |                                          |
|  Chicago Sun-Times   | 1948-01-01 | 63      | True    | 1.27        | 14:57:13 | 1948-01-01T14:57:13 |              | Extra data past headers will be trimmed  |
|  Chicago Reader      | 1971-01-01 | 40      | True    | 1.0         | 04:14:00 | 1971-01-01T04:14:00 |              |                                          |
|  This row has blanks |            |         |         |             |          |                     |              |                                          |
|  Unicode!            |            |         |         |             |          |                     |              |                                          |
|----------------------+------------+---------+---------+-------------+----------+---------------------+--------------+------------------------------------------|
Tue Jan 20 12:47:42 2015 vakorol
binmode STDIN,':utf8';$j=0,@{$a[$i++]}=map{s/^"|\n$//g;s/""/"/g;$m[$j-1]=$l if($l=length)>$m[$j++];$_}split/"?,/,$_ while<>;($t,$s,$g)=$y&&$y!=2&&$y<@a+2?(' ','','|'):qw/- - +/,$k=0,print("|$t".(join$g,map{($S=$s x$m[$k])||=$_;sprintf"$t%-$m[$k++]s$t",$S}@$_)."$t|\n"),++$y>@a+2?last:($s||$y==@a+2)&&redo for@a
310 symbols perl failed test 3 Wrong answer
|----------------------+------------+---------+---------+-------------+----------+---------------------+--------------+------------------------------------------|
|  text                | date       | integer | boolean | float       | time     | datetime            | empty_column | _unnamed                                 |
|----------------------+------------+---------+---------+-------------+----------+---------------------+--------------+------------------------------------------|
|  Chicago Tribune     | 1920-01-01 | 164     | False   | 41800000.01 | 00:00:00 | 1920-01-01T00:00:00 |              |                                          |
|  Chicago Sun-Times   | 1948-01-01 | 63      | True    | 1.27        | 14:57:13 | 1948-01-01T14:57:13 |              | Extra data past headers will be trimmed  |
|  Chicago Reader      | 1971-01-01 | 40      | True    | 1.0         | 04:14:00 | 1971-01-01T04:14:00 |              |                                          |
|  This row has blanks |            |         |         |             |          |                     |              |                                          |
|  Unicode!             |
|-----------------------|
instead of
|----------------------+------------+---------+---------+-------------+----------+---------------------+--------------+------------------------------------------|
|  text                | date       | integer | boolean | float       | time     | datetime            | empty_column | _unnamed                                 |
|----------------------+------------+---------+---------+-------------+----------+---------------------+--------------+------------------------------------------|
|  Chicago Tribune     | 1920-01-01 | 164     | False   | 41800000.01 | 00:00:00 | 1920-01-01T00:00:00 |              |                                          |
|  Chicago Sun-Times   | 1948-01-01 | 63      | True    | 1.27        | 14:57:13 | 1948-01-01T14:57:13 |              | Extra data past headers will be trimmed  |
|  Chicago Reader      | 1971-01-01 | 40      | True    | 1.0         | 04:14:00 | 1971-01-01T04:14:00 |              |                                          |
|  This row has blanks |            |         |         |             |          |                     |              |                                          |
|  Unicode!            |            |         |         |             |          |                     |              |                                          |
|----------------------+------------+---------+---------+-------------+----------+---------------------+--------------+------------------------------------------|
Tue Jan 20 13:00:14 2015 vakorol
binmode STDIN,':utf8';$j=0,@{$a[$i++]}=map{s/^"|\n$//g;s/""/"/g;$m[$j-1]=$l if($l=length)>$m[$j++];$_}split/"?,/,$_ while<>;($t,$s,$g)=$y&&$y!=2&&$y<@a+2?(' ','','|'):qw/- - +/,$k=0,print("|$t".(join$g,map{($S=$s x$m[$k])||=$_;sprintf"$t%-$m[$k++]s$t",$S}@$_)."$t|\n"),++$y>@a+2?last:($s||$y==@a+2)&&redo for@a
337 symbols perl failed test 3 Wrong answer
|----------------------+------------+---------+---------+-------------+----------+---------------------+--------------+------------------------------------------|
|  text                | date       | integer | boolean | float       | time     | datetime            | empty_column | _unnamed                                 |
|----------------------+------------+---------+---------+-------------+----------+---------------------+--------------+------------------------------------------|
|  Chicago Tribune     | 1920-01-01 | 164     | False   | 41800000.01 | 00:00:00 | 1920-01-01T00:00:00 |              |                                          |
|  Chicago Sun-Times   | 1948-01-01 | 63      | True    | 1.27        | 14:57:13 | 1948-01-01T14:57:13 |              | Extra data past headers will be trimmed  |
|  Chicago Reader      | 1971-01-01 | 40      | True    | 1.0         | 04:14:00 | 1971-01-01T04:14:00 |              |                                          |
|  This row has blanks |            |         |         |             |          |                     |              |                                          |
|  Unicode!             |
|-----------------------|
instead of
|----------------------+------------+---------+---------+-------------+----------+---------------------+--------------+------------------------------------------|
|  text                | date       | integer | boolean | float       | time     | datetime            | empty_column | _unnamed                                 |
|----------------------+------------+---------+---------+-------------+----------+---------------------+--------------+------------------------------------------|
|  Chicago Tribune     | 1920-01-01 | 164     | False   | 41800000.01 | 00:00:00 | 1920-01-01T00:00:00 |              |                                          |
|  Chicago Sun-Times   | 1948-01-01 | 63      | True    | 1.27        | 14:57:13 | 1948-01-01T14:57:13 |              | Extra data past headers will be trimmed  |
|  Chicago Reader      | 1971-01-01 | 40      | True    | 1.0         | 04:14:00 | 1971-01-01T04:14:00 |              |                                          |
|  This row has blanks |            |         |         |             |          |                     |              |                                          |
|  Unicode!            |            |         |         |             |          |                     |              |                                          |
|----------------------+------------+---------+---------+-------------+----------+---------------------+--------------+------------------------------------------|
Tue Jan 20 14:51:53 2015 avkhozov
binmode STDIN,':utf8'; binmode STDOUT,':utf8';
$j=0,@{$a[$i++]}=map{s/^"|\n$//g;s/""/"/g;$m[$j-1]=$l if($l=length)>$m[$j++];$_}split/"?,/,$_ while<>;($t,$s,$g)=$y&&$y!=2&&$y<@a+2?(' ','','|'):qw/- - +/,$k=0,print("|$t".(join$g,map{($S=$s x$m[$k])||=$_;sprintf"$t%-$m[$k++]s$t",$S}@$_)."$t|\n"),++$y>@a+2?last:($s||$y==@a+2)&&redo for@a

310 symbols perl failed test 3 Wrong answer
|----------------------+------------+---------+---------+-------------+----------+---------------------+--------------+------------------------------------------|
|  text                | date       | integer | boolean | float       | time     | datetime            | empty_column | _unnamed                                 |
|----------------------+------------+---------+---------+-------------+----------+---------------------+--------------+------------------------------------------|
|  Chicago Tribune     | 1920-01-01 | 164     | False   | 41800000.01 | 00:00:00 | 1920-01-01T00:00:00 |              |                                          |
|  Chicago Sun-Times   | 1948-01-01 | 63      | True    | 1.27        | 14:57:13 | 1948-01-01T14:57:13 |              | Extra data past headers will be trimmed  |
|  Chicago Reader      | 1971-01-01 | 40      | True    | 1.0         | 04:14:00 | 1971-01-01T04:14:00 |              |                                          |
|  This row has blanks |            |         |         |             |          |                     |              |                                          |
|  Unicode!             |
|-----------------------|
instead of
|----------------------+------------+---------+---------+-------------+----------+---------------------+--------------+------------------------------------------|
|  text                | date       | integer | boolean | float       | time     | datetime            | empty_column | _unnamed                                 |
|----------------------+------------+---------+---------+-------------+----------+---------------------+--------------+------------------------------------------|
|  Chicago Tribune     | 1920-01-01 | 164     | False   | 41800000.01 | 00:00:00 | 1920-01-01T00:00:00 |              |                                          |
|  Chicago Sun-Times   | 1948-01-01 | 63      | True    | 1.27        | 14:57:13 | 1948-01-01T14:57:13 |              | Extra data past headers will be trimmed  |
|  Chicago Reader      | 1971-01-01 | 40      | True    | 1.0         | 04:14:00 | 1971-01-01T04:14:00 |              |                                          |
|  This row has blanks |            |         |         |             |          |                     |              |                                          |
|  Unicode!            |            |         |         |             |          |                     |              |                                          |
|----------------------+------------+---------+---------+-------------+----------+---------------------+--------------+------------------------------------------|
Tue Jan 20 15:44:38 2015 vakorol
binmode STDIN,':utf8';$j=0,@{$a[$i++]}=map{s/^"|\n$//g;s/""/"/g;$m[$j-1]=$l if($l=length)>$m[$j++];$_}split/"?,/,$_ while<>;($t,$s,$g)=$y&&$y!=2&&$y<@a+2?(' ','','|'):qw/- - +/,$k=0,print("|$t".(join$g,map{($S=$s x$m[$k])||=$_;sprintf"$t%-$m[$k++]s$t",$S}@$_)."$t|\n"),++$y>@a+2?last:($s||$y==@a+2)&&redo for@a
288 symbols perl failed test 3 Wrong answer
|----------------------+------------+---------+---------+-------------+----------+---------------------+--------------+------------------------------------------|
|  text                | date       | integer | boolean | float       | time     | datetime            | empty_column | _unnamed                                 |
|----------------------+------------+---------+---------+-------------+----------+---------------------+--------------+------------------------------------------|
|  Chicago Tribune     | 1920-01-01 | 164     | False   | 41800000.01 | 00:00:00 | 1920-01-01T00:00:00 |              |                                          |
|  Chicago Sun-Times   | 1948-01-01 | 63      | True    | 1.27        | 14:57:13 | 1948-01-01T14:57:13 |              | Extra data past headers will be trimmed  |
|  Chicago Reader      | 1971-01-01 | 40      | True    | 1.0         | 04:14:00 | 1971-01-01T04:14:00 |              |                                          |
|  This row has blanks |            |         |         |             |          |                     |              |                                          |
|  Unicode!             |
|-----------------------|
instead of
|----------------------+------------+---------+---------+-------------+----------+---------------------+--------------+------------------------------------------|
|  text                | date       | integer | boolean | float       | time     | datetime            | empty_column | _unnamed                                 |
|----------------------+------------+---------+---------+-------------+----------+---------------------+--------------+------------------------------------------|
|  Chicago Tribune     | 1920-01-01 | 164     | False   | 41800000.01 | 00:00:00 | 1920-01-01T00:00:00 |              |                                          |
|  Chicago Sun-Times   | 1948-01-01 | 63      | True    | 1.27        | 14:57:13 | 1948-01-01T14:57:13 |              | Extra data past headers will be trimmed  |
|  Chicago Reader      | 1971-01-01 | 40      | True    | 1.0         | 04:14:00 | 1971-01-01T04:14:00 |              |                                          |
|  This row has blanks |            |         |         |             |          |                     |              |                                          |
|  Unicode!            |            |         |         |             |          |                     |              |                                          |
|----------------------+------------+---------+---------+-------------+----------+---------------------+--------------+------------------------------------------|
Tue Jan 20 15:48:07 2015 vakorol
$j=0,@{$a[$i++]}=map{s/^"|\n$//g;s/""/"/g;$m[$j-1]=$l if($l=length)>$m[$j++];$_}split/"?,/,$_ while<>;($t,$s,$g)=$y&&$y!=2&&$y<@a+2?(' ','','|'):qw/- - +/,$k=0,print("|$t".(join$g,map{($S=$s x$m[$k])||=$_;sprintf"$t%-$m[$k++]s$t",$S}@$_)."$t|\n"),++$y>@a+2?last:($s||$y==@a+2)&&redo for@a
310 symbols perl failed test 3 Wrong answer
|----------------------+------------+---------+---------+-------------+----------+---------------------+--------------+------------------------------------------|
|  text                | date       | integer | boolean | float       | time     | datetime            | empty_column | _unnamed                                 |
|----------------------+------------+---------+---------+-------------+----------+---------------------+--------------+------------------------------------------|
|  Chicago Tribune     | 1920-01-01 | 164     | False   | 41800000.01 | 00:00:00 | 1920-01-01T00:00:00 |              |                                          |
|  Chicago Sun-Times   | 1948-01-01 | 63      | True    | 1.27        | 14:57:13 | 1948-01-01T14:57:13 |              | Extra data past headers will be trimmed  |
|  Chicago Reader      | 1971-01-01 | 40      | True    | 1.0         | 04:14:00 | 1971-01-01T04:14:00 |              |                                          |
|  This row has blanks |            |         |         |             |          |                     |              |                                          |
|  Unicode!             |
|-----------------------|
instead of
|----------------------+------------+---------+---------+-------------+----------+---------------------+--------------+------------------------------------------|
|  text                | date       | integer | boolean | float       | time     | datetime            | empty_column | _unnamed                                 |
|----------------------+------------+---------+---------+-------------+----------+---------------------+--------------+------------------------------------------|
|  Chicago Tribune     | 1920-01-01 | 164     | False   | 41800000.01 | 00:00:00 | 1920-01-01T00:00:00 |              |                                          |
|  Chicago Sun-Times   | 1948-01-01 | 63      | True    | 1.27        | 14:57:13 | 1948-01-01T14:57:13 |              | Extra data past headers will be trimmed  |
|  Chicago Reader      | 1971-01-01 | 40      | True    | 1.0         | 04:14:00 | 1971-01-01T04:14:00 |              |                                          |
|  This row has blanks |            |         |         |             |          |                     |              |                                          |
|  Unicode!            |            |         |         |             |          |                     |              |                                          |
|----------------------+------------+---------+---------+-------------+----------+---------------------+--------------+------------------------------------------|
Fri Feb 13 14:15:21 2015 vakorol
binmode STDIN,':utf8';$j=0,@{$a[$i++]}=map{s/^"|\n$//g;s/""/"/g;$m[$j-1]=$l if($l=length)>$m[$j++];$_}split/"?,/,$_ while<>;($t,$s,$g)=$y&&$y!=2&&$y<@a+2?(' ','','|'):qw/- - +/,$k=0,print("|$t".(join$g,map{($S=$s x$m[$k])||=$_;sprintf"$t%-$m[$k++]s$t",$S}@$_)."$t|\n"),++$y>@a+2?last:($s||$y==@a+2)&&redo for@a
289 symbols perl failed test 3 Wrong answer
|----------------------+------------+---------+---------+-------------+----------+---------------------+--------------+------------------------------------------|
|  text                | date       | integer | boolean | float       | time     | datetime            | empty_column | _unnamed                                 |
|----------------------+------------+---------+---------+-------------+----------+---------------------+--------------+------------------------------------------|
|  Chicago Tribune     | 1920-01-01 | 164     | False   | 41800000.01 | 00:00:00 | 1920-01-01T00:00:00 |              |                                          |
|  Chicago Sun-Times   | 1948-01-01 | 63      | True    | 1.27        | 14:57:13 | 1948-01-01T14:57:13 |              | Extra data past headers will be trimmed  |
|  Chicago Reader      | 1971-01-01 | 40      | True    | 1.0         | 04:14:00 | 1971-01-01T04:14:00 |              |                                          |
|  This row has blanks |            |         |         |             |          |                     |              |                                          |
|  Unicode!             |
|-----------------------|
instead of
|----------------------+------------+---------+---------+-------------+----------+---------------------+--------------+------------------------------------------|
|  text                | date       | integer | boolean | float       | time     | datetime            | empty_column | _unnamed                                 |
|----------------------+------------+---------+---------+-------------+----------+---------------------+--------------+------------------------------------------|
|  Chicago Tribune     | 1920-01-01 | 164     | False   | 41800000.01 | 00:00:00 | 1920-01-01T00:00:00 |              |                                          |
|  Chicago Sun-Times   | 1948-01-01 | 63      | True    | 1.27        | 14:57:13 | 1948-01-01T14:57:13 |              | Extra data past headers will be trimmed  |
|  Chicago Reader      | 1971-01-01 | 40      | True    | 1.0         | 04:14:00 | 1971-01-01T04:14:00 |              |                                          |
|  This row has blanks |            |         |         |             |          |                     |              |                                          |
|  Unicode!            |            |         |         |             |          |                     |              |                                          |
|----------------------+------------+---------+---------+-------------+----------+---------------------+--------------+------------------------------------------|
Fri Feb 13 14:19:26 2015 vakorol
$j=0,@{$a[$i++]}=map{s/^"|\n?$//g;s/""/"/g;$m[$j-1]=$l if($l=length)>$m[$j++];$_}split/"?,/,$_ while<>;($t,$s,$g)=$y&&$y!=2&&$y<@a+2?(' ','','|'):qw/- - +/,$k=0,print("|$t".(join$g,map{($S=$s x$m[$k])||=$_;sprintf"$t%-$m[$k++]s$t",$S}@$_)."$t|\n"),++$y>@a+2?last:($s||$y==@a+2)&&redo for@a

View all solutions