Fread bug in reading file with quotes

Open
#4,221 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
38/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
r
Domain
data

Research direction

Start by running the supplied data.table, fwrite, readLines, and fread reproducer with the quoted CSV. Trace fread's handling of quoted headers and fields, then verify that the file is read with one column and without the reported warnings.

Written by the indexing model from the issue text.

Description

fread
require(data.table) # today's devel
(dt <- data.table(my_col = Sys.time()))
#                 my_col
# 1: 2020-01-31 19:43:48
fwrite(dt, file="~/Downloads/tmp.csv", quote=TRUE, dateTimeAs="write.csv")
readLines("~/Downloads/tmp.csv")
# [1] "\"my_col\""              "\"2020-01-31 19:43:48\""
fread("~/Downloads/tmp.csv")
#             V1  "my_col"
# 1: "2020-01-31 19:43:48"
# Warning messages:
# 1: In fread("~/Downloads/tmp.csv") :
#   Found and resolved improper quoting in first 100 rows. If the fields are not quoted (e.g. field separator does not appear within any field), try quote="" to avoid this warning.
# 2: In fread("~/Downloads/tmp.csv") :
#   Detected 1 column names but the data has 2 columns (i.e. invalid file). Added 1 extra default column name for the first column which is guessed to be row names or an index. Use setnames() afterwards if this guess is not correct, or fix the file write command that created the file to create a valid file.
Dominant language
R
Stars
3.9k
Forks
1.1k
Avg merge
14h 4m
Merged PRs (30d)
4

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Rdatatable/data.table

All issues in Rdatatable/data.table

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.