首页 > 其他 > 详细

(转载)PERL 处理CSV

时间:2014-12-24 11:37:17      阅读:210      评论:0      收藏:0      [点我收藏+]

#!/usr/bin/perl
#use strict;
open(FILE1,"C:/Perl/BX/BX-Users.csv");
open(FILE2,"C:/Perl/BX/BX-Books.csv");
open(FILE3,"C:/Perl/BX/BX-Book-Ratings.csv");
 
open(result1,">C:/Perl/BX/BX-Users.txt");
my %table;
my $record1;
my $count1;
#my $i=0;
<FILE1>;
while($_=<FILE1>)
{
    if($_ =~ /NULL$/){
         
     
        next
 
 
    }
    else{
    s/"//g;
    my @list=split /;/,$_;
    #print"@list";
    push @{$table{$list[0]}},$list[2];
    #print "$record1";
    #$i++;
    }
     
     
}
foreach my $userId(sort keys %table)
{
    my @AGE=@{$table{$userId}};
    syswrite(result1,"$userId,@AGE");
    $count1++;
}
print "$count1";
close(FILE1);
close(result1);
 
close(FILE2);
close(FILE3);

(转载)PERL 处理CSV

原文:http://www.cnblogs.com/hzj680539/p/4181963.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!