{"action":"created","issue":{"url":"https://api.github.com/repos/Rdatatable/data.table/issues/1518","repository_url":"https://api.github.com/repos/Rdatatable/data.table","labels_url":"https://api.github.com/repos/Rdatatable/data.table/issues/1518/labels{/name}","comments_url":"https://api.github.com/repos/Rdatatable/data.table/issues/1518/comments","events_url":"https://api.github.com/repos/Rdatatable/data.table/issues/1518/events","html_url":"https://github.com/Rdatatable/data.table/pull/1518","id":131408719,"number":1518,"title":"readLines with fread","user":{"login":"dselivanov","id":5123805,"avatar_url":"https://avatars.githubusercontent.com/u/5123805?v=3","gravatar_id":"","url":"https://api.github.com/users/dselivanov","html_url":"https://github.com/dselivanov","followers_url":"https://api.github.com/users/dselivanov/followers","following_url":"https://api.github.com/users/dselivanov/following{/other_user}","gists_url":"https://api.github.com/users/dselivanov/gists{/gist_id}","starred_url":"https://api.github.com/users/dselivanov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dselivanov/subscriptions","organizations_url":"https://api.github.com/users/dselivanov/orgs","repos_url":"https://api.github.com/users/dselivanov/repos","events_url":"https://api.github.com/users/dselivanov/events{/privacy}","received_events_url":"https://api.github.com/users/dselivanov/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Rdatatable/data.table/labels/Enhancement","name":"Enhancement","color":"bfe5bf"},{"url":"https://api.github.com/repos/Rdatatable/data.table/labels/fread","name":"fread","color":"207de5"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/Rdatatable/data.table/milestones/3","html_url":"https://github.com/Rdatatable/data.table/milestones/v1.9.8","labels_url":"https://api.github.com/repos/Rdatatable/data.table/milestones/3/labels","id":812342,"number":3,"title":"v1.9.8","description":"","creator":{"login":"arunsrinivasan","id":3102045,"avatar_url":"https://avatars.githubusercontent.com/u/3102045?v=3","gravatar_id":"","url":"https://api.github.com/users/arunsrinivasan","html_url":"https://github.com/arunsrinivasan","followers_url":"https://api.github.com/users/arunsrinivasan/followers","following_url":"https://api.github.com/users/arunsrinivasan/following{/other_user}","gists_url":"https://api.github.com/users/arunsrinivasan/gists{/gist_id}","starred_url":"https://api.github.com/users/arunsrinivasan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arunsrinivasan/subscriptions","organizations_url":"https://api.github.com/users/arunsrinivasan/orgs","repos_url":"https://api.github.com/users/arunsrinivasan/repos","events_url":"https://api.github.com/users/arunsrinivasan/events{/privacy}","received_events_url":"https://api.github.com/users/arunsrinivasan/received_events","type":"User","site_admin":false},"open_issues":51,"closed_issues":103,"state":"open","created_at":"2014-10-03T08:24:10Z","updated_at":"2016-03-09T01:21:02Z","due_on":null,"closed_at":null},"comments":12,"created_at":"2016-02-04T16:54:20Z","updated_at":"2016-03-09T19:38:39Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Rdatatable/data.table/pulls/1518","html_url":"https://github.com/Rdatatable/data.table/pull/1518","diff_url":"https://github.com/Rdatatable/data.table/pull/1518.diff","patch_url":"https://github.com/Rdatatable/data.table/pull/1518.patch"},"body":"It is tricky to use `fread` as replacement for `readLines` for reading non-tabular raw text data. In fact I realised that I actually can do that only after creating this PR.\r\nConsider following example where I want to read text without splitting it into `data.frame`/`data.table`\r\n```r\r\ntxt <- fread('a,b\\n ab,cd,ce\\n abcdef\\n hjkli \\n')\r\n# Error in fread(\"a,b\\n ab,cd,ce\\n abcdef\\n hjkli \\n\") : \r\n#  Expected sep (',') but new line, EOF (or other non printing character) ends field 0 when detecting types (   first):  abcdef\r\n#In addition: Warning message:\r\n#In fread(\"a,b\\n ab,cd,ce\\n abcdef\\n hjkli \\n\") :\r\n#  Starting data input on line 2 and discarding line 1 because it has too few or too many items to be column names or data: a,b\r\n```\r\nFortunately (and I realised that only after browsing `fread.c` source code) we can pass `sep = \"\\n\"`.\r\n```r\r\ntxt <- fread('a,b\\n ab,cd,ce\\n abcdef\\n hjkli \\n', sep = '\\n')\r\n#        a,b\r\n#1: ab,cd,ce\r\n#2:   abcdef\r\n#3:    hjkli\r\n```\r\nNote, that we received  `\"hjkli\"`, not `\" hjkli \"`, because `strip.white = TRUE` by default. This also can be misleading.\r\n\r\nAnd the last - most painful. It is not possible to do trick above on windows, where `EOL = '\\r\\n'`:\r\n```r\r\nfread(\"a,b\\n ab,cd,ce\\n abcdef\\n hjkli \\n\", sep = \"\\r\\n\")\r\n#Error in fread(\"a,b\\n ab,cd,ce\\n abcdef\\n hjkli \\n\", sep = \"\\r\\n\") : \r\n#  'sep' must be 'auto' or a single character\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/Rdatatable/data.table/issues/comments/194471780","html_url":"https://github.com/Rdatatable/data.table/pull/1518#issuecomment-194471780","issue_url":"https://api.github.com/repos/Rdatatable/data.table/issues/1518","id":194471780,"user":{"login":"arunsrinivasan","id":3102045,"avatar_url":"https://avatars.githubusercontent.com/u/3102045?v=3","gravatar_id":"","url":"https://api.github.com/users/arunsrinivasan","html_url":"https://github.com/arunsrinivasan","followers_url":"https://api.github.com/users/arunsrinivasan/followers","following_url":"https://api.github.com/users/arunsrinivasan/following{/other_user}","gists_url":"https://api.github.com/users/arunsrinivasan/gists{/gist_id}","starred_url":"https://api.github.com/users/arunsrinivasan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arunsrinivasan/subscriptions","organizations_url":"https://api.github.com/users/arunsrinivasan/orgs","repos_url":"https://api.github.com/users/arunsrinivasan/repos","events_url":"https://api.github.com/users/arunsrinivasan/events{/privacy}","received_events_url":"https://api.github.com/users/arunsrinivasan/received_events","type":"User","site_admin":false},"created_at":"2016-03-09T19:38:39Z","updated_at":"2016-03-09T19:38:39Z","body":"`sep=\"\\n\"` looks natural to me. Why does `sep=NULL` look more natural to you? Not sure what you mean by split/parse.. it still has to take care of embedded `\\n`s, isn't it?"}}