我需要导入一个包含2000万行和2列的csv文件到数据库,但是当我尝试使用mysql workbench的数据导入向导这样做非常慢时,可能需要1个月才能完成,看着进度条.我希望,必须有一些更快的方法来做到这一点.非常感谢你
我的脚本相当大,但我会在这里简化代码.假设我创建了一个CSV并且我像这样写了标题:
my $csv = Text::CSV->new ({binary => 1}, eol => "\n");
open(my $out, ">", "$dir/out.csv") or die $!; #create
$out->print("CodeA,CodeB,Name,Count,Pos,Orientation\n"); #I write the header
Run Code Online (Sandbox Code Playgroud)
假设我得到了一些存储在不同变量中的值,我想将这些变量写成CSV中的一行.我无法弄清楚如何,因为在Text :: CSV文档中没有清楚地解释打印,没有直接的例子,我不知道数组引用是什么.
在Perl中我试图实现这个目标:
while ($row = <$fh>){
if the row contains the character >:
#do something AND then skip to the next line
else:
#continue to parse normally and do other things
Run Code Online (Sandbox Code Playgroud)