DBD::CSV:如何使用两个 f_ext-options“.csv”生成不同的行为?和“.csv/r”?
这是来自 DBD::File 文档:
f_ext
此属性用于设置打开 (CSV) 文件的文件扩展名。有几种可能性。
DBI:CSV:f_dir=data;f_ext=.csv
在这种情况下,如果 datadir 中同时存在 table.csv 和 table,则 DBD::File 将仅打开 table.csv。该表仍将命名为 table。如果您的 datadir 包含带有扩展名的文件,并且您没有传递此属性,则您的表将被命名为 table.csv,这可能不是您想要的。扩展名始终不区分大小写。表名不是。
DBI:CSV:f_dir=data;f_ext=.csv/r
在这种情况下,需要扩展名,并且所有不匹配的文件名都将被忽略。
我不可能使用“.csv/r”和“.csv”这两个选项生成不同的行为。有人可以给我举一个例子,让我可以看到“.csv/r”和“.csv”之间的区别吗?
This is from the DBD::File-documentation:
f_ext
This attribute is used for setting the file extension where (CSV) files are opened. There are several possibilities.
DBI:CSV:f_dir=data;f_ext=.csv
In this case, DBD::File will open only table.csv if both table.csv and table exist in the datadir. The table will still be named table. If your datadir has files with extensions, and you do not pass this attribute, your table is named table.csv, which is probably not what you wanted. The extension is always case-insensitive. The table names are not.
DBI:CSV:f_dir=data;f_ext=.csv/r
In this case the extension is required, and all filenames that do not match are ignored.
It was not possible for me to generate different behavior with the two options ".csv/r" and ".csv". Could someone show me an example, where I can see the difference between ".csv/r" and ".csv"?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我似乎也无法让它做任何不同的事情。代码的相关部分是
I can't seem to get it to do anything different either. The relevant section of code is
这是否表明了差异?:
f_ext=.csv
仅使.csv
成为首选项,但不是要求:在第一种情况下,文件“bar”没有仍使用 .csv 扩展名,但选择“foo.csv”而不是“foo”。对于f_ext=.csv/r"
,“bar”将被忽略,因为它没有“.csv”扩展名。Does this demonstrate the difference?:
f_ext=.csv
only makes the.csv
a preference, but nor a requirement: in the first case, the file "bar" with no .csv extension is still used, but "foo.csv" is chosen over "foo". Withf_ext=.csv/r"
, "bar" is ignored, as it has no ".csv" extension.现在,在 DBD::File 的 0.39 版本中,这部分看起来像这样:
据我所知,两个 f_ext-options 正在按预期工作。
Now in version 0.39 of DBD::File this part looks like this:
As far as I can see, the two f_ext-options are working as expected.