java实现fread_带有反斜杠的fread和column

我有一个问题,fread()使用“\”作为目录分隔符读取一列目录路径 . 问题是尾随目录分隔符在fread()中引发错误 .

对于以下示例csv文件,

file,size

"windows\user",123

fread()和read.csv()都同意并且都将\转换为\

> fread("example.csv")

file size

1: windows\\user 123

但是,对于以下示例,fread()在read.csv()没问题时给出错误 .

file,size

"windows\user\",123

read.csv()给出

> read.csv("example.csv")

file size

1 windows\\user\\ 123

虽然fread()错误看起来像这样

> fread("example.csv",verbose=TRUE)

Input contains no \n. Taking this to be a filename to open

File opened, filesize is 0.000 GB

File is opened and mapped ok

Detected eol as \r\n (CRLF) in that order, the Windows standard.

Using line 2 to detect sep (the last non blank line in the first 'autostart') ... sep=','

Found 2 columns

First row with 2 fields occurs on line 1 (either column names or first row of data)

All the fields on line 1 are character fields. Treating as the column names.

Count of eol after first data row: 2

Subtracted 1 for last eol and any trailing empty lines, leaving 1 data rows

Error in fread("example.csv", verbose = TRUE) :

' ends field 1 on line 1 when detecting types: "windows\user\",123

我真的想避免这样做

DT = data.table(read.csv("example.csv"))

如果可能的话 .

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值