gpt4 book ai didi

r - data.table::fread 和不平衡"

转载 作者:行者123 更新时间:2023-12-05 00:30:24 26 4
gpt4 key购买 nike

当我尝试使用 data.table:fread(fn, sep='\t', header=T) 读取 csv 文件时, 它给出了“在此行上观察到的不平衡”错误。数据有 3 个整数变量和 1 个字符串变量。csv 文件中的字符串没有用 " 括起来,是的,有些行包含 "在字符串变量中," 字符不是成对的。

我想知道是否可以让fread忽略未配对的 "在变量中并继续读取数据?谢谢。

这是示例数据(只有一条记录)

N_ID    VISIT_DATE  REQ_URL REQType
175931 2013-3-8 23:40:30 http://aaa.com/rest/api2.do?api=getSetMobileSession&data={"imei":"60893ZTE-CN13cd","appkey":"android_client","content":"Z0JiRA0qPFtWM3BYVltmcx5MWF9ZS0YLdW1ydXoqPycuJS8idXdlY3R0TGBtU 1

最佳答案

更新:现在在 v1.8.11 中实现

来自新闻:

fread now accepts quotes (both ' and ") in the middle of fields, whether the field starts with " or not, rather than the 'unbalanced quotes' error, #2694. Thanks to baidao for reporting. It was known and documented at the top of ?fread (text now removed). If a field starts with " it must end with " (necessary if the field separator itself is in the field contents). Embedded quotes can be in column names too. Newlines (\n) still can't be in quoted fields or quoted column names, yet.



是的,正如@agstudy 所说,嵌入式引号是自 fread 以来尚未实现的已知记录问题。是新的。严格来说,我认为这些不是嵌入的,因为您示例中的字符串不以引号开头。

无论如何,我已将此作为错误报告提交,因此不会被遗忘。将在下一个版本中完成。谢谢你的强调。

#2694 : Strings including quotes but not starting with quote in fread

关于r - data.table::fread 和不平衡",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16094025/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com