使用Perl Text :: CSV解析具有特殊字符的字段
发布时间:2020-12-15 21:47:54 所属栏目:大数据 来源:网络整理
导读:我正在使用 Text::CSV 模块从一个以制表符分隔的值文件中将行解析为各个字段. 字符串中的特殊字符的示例是 "CEZARY ??UKASZEWICZ,PAWE?? WIETESKA","BüRO FüR" 我的代码如下: my $file = $ARGV[0] or die "Need to get TSV file on the command linen";m
我正在使用
Text::CSV 模块从一个以制表符分隔的值文件中将行解析为各个字段.
字符串中的特殊字符的示例是 "CEZARY ??UKASZEWICZ,PAWE?? WIETESKA","BüRO FüR" 我的代码如下: my $file = $ARGV[0] or die "Need to get TSV file on the command linen"; my $csv = Text::CSV->new({sep_char => "t"}); open(my $data,'<',$file) or die "Could not open '$file' $!n"; while (my $line= <$data>) { if($csv->parse($line)){ my @curr_arr = $csv->fields(); } } # end of while close $data; 以上是我的代码的一些重要部分.我得到的错误如下: cvs_xs error : 2026 - EIQ - Binary Character inside quoted field,binary off @pos 15 解决方法my $csv = Text::CSV->new({ binary => 1,sep_char => "t"}); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |