小编use*_*843的帖子

读取CSV文件并保存为2 d阵列

我试图在二维数组中读取一个巨大的CSV文件,必须有一个更好的方法来分割线并一步保存在二维数组中:s干杯

my $j = 0;
while (<IN>) 
{

    chomp ;
    my @cols=();
    @cols   = split(/,/); 
    shift(@cols) ; #to remove the first number which is a line header
    for(my $i=0; $i<11; $i++) 
    {
       $array[$i][$j]  = $cols[$i];
    }        
    $j++;    
}
Run Code Online (Sandbox Code Playgroud)

arrays perl

4
推荐指数
2
解决办法
1万
查看次数

标签 统计

arrays ×1

perl ×1