fread 和带引号的多行列值 [英] fread and a quoted multi-line column value

查看:14
本文介绍了fread 和带引号的多行列值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

> fread('col1,col2
')
Empty data.table (0 rows) of 2 cols: col1,col2
> fread('col1,col2
5,4')
   col1 col2
1:    5    4
> fread('col1,col2
5,"4
3"')
Error in fread("col1,col2
5,"4
3"") : 
  Unbalanced quote (") observed on this line: 3"
> 

read.csv 可以导入此 csv,只要跨越多行的值包含在引号中.

read.csv can import this csv as long as the value that spans multiple lines is wrapped in quotes.

fread 也应该能够导入它吗?使用 read.csv 对于我的用例来说实际上很好.我可以将生成的数据框转换为数据表.但我只是想确保没有这个功能是一个设计决定,而不是尚未经过测试的东西.

Should fread be able to import it as well? Using read.csv is actually fine for my use case. I can just convert the resulting data frame into a data table. But I just wanted to make sure that not having this functionality was a design decision, and not something that just wasn't yet tested.

推荐答案

更新:现已在 v1.9.3 中修复 GitHub :

UPDATE: Now fixed in v1.9.3 on GitHub :

  • fread() 现在接受带引号的字段内的换行符.感谢 Clayton Stanley 强调.


这个错误之前已经报告过,它在列表中.但这里的新功能是引号内的 .我没有意识到这是一个导致错误的用例.

This error has been reported before and it's on the list to do. But what's new here is the inside the quotes. I hadn't realised that was a use case giving rise to the error.

非常感谢您的报告.会修好的.

Many thanks for reporting. It'll be fixed.

类似的问题,但这里不完全相同:

Similar question but not exactly the same here :

data.table::fread 和不平衡的"

错误报告在这里:

https://r-forge.r-project.org/tracker/?group_id=240&atid=975&func=detail&aid=2694

这篇关于fread 和带引号的多行列值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆