使用 perl 创建 csv 文件
我在 Windows 上使用这个 perl 模块 Text::CSV_XS 创建了 csv 文件:
下面是我的代码片段:
use Text::CSV_XS;
my @a =('ID','VALUE');
open my $OUTPUT,'>',"file.csv" or die "Can't able to open file.csv\n";
my $csv = Text::CSV_XS->new ({ binary => 1, eol => $/ });
$csv->print($OUTPUT,\@a);
此代码生成一个 file.csv,但是当我尝试使用 xls 打开 file.csv 时,xls 会写入该文件是 SYLK 并且不知道有人可以帮忙为什么这个 csv 无法用 xls 打开吗?
I created csv file with this perl module Text::CSV_XS on windows:
Below a snippet of my code :
use Text::CSV_XS;
my @a =('ID','VALUE');
open my $OUTPUT,'>',"file.csv" or die "Can't able to open file.csv\n";
my $csv = Text::CSV_XS->new ({ binary => 1, eol => $/ });
$csv->print($OUTPUT,\@a);
this code generate a file.csv but when I try to open the file.csv with xls the xls write that this file is SYLK and can't know it could someone help why this csv can't open with xls?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您打开文本文件或 CSV 文件并且文件的前两个字符是大写字母“I”和“D”时,会出现此问题
打开文件时出现“SYLK:文件格式无效”错误消息
This problem occurs when you open a text file or CSV file and the first two characters of the file are the uppercase letters "I" and "D"
"SYLK: File format is not valid" error message when you open file