{"action":"created","issue":{"url":"https://api.github.com/repos/Rdatatable/data.table/issues/2376","repository_url":"https://api.github.com/repos/Rdatatable/data.table","labels_url":"https://api.github.com/repos/Rdatatable/data.table/issues/2376/labels{/name}","comments_url":"https://api.github.com/repos/Rdatatable/data.table/issues/2376/comments","events_url":"https://api.github.com/repos/Rdatatable/data.table/issues/2376/events","html_url":"https://github.com/Rdatatable/data.table/issues/2376","id":259536012,"number":2376,"title":"fread(strip.white = FALSE) does not retain leading whitespace in first column","user":{"login":"HughParsonage","id":8111628,"avatar_url":"https://avatars1.githubusercontent.com/u/8111628?v=4","gravatar_id":"","url":"https://api.github.com/users/HughParsonage","html_url":"https://github.com/HughParsonage","followers_url":"https://api.github.com/users/HughParsonage/followers","following_url":"https://api.github.com/users/HughParsonage/following{/other_user}","gists_url":"https://api.github.com/users/HughParsonage/gists{/gist_id}","starred_url":"https://api.github.com/users/HughParsonage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HughParsonage/subscriptions","organizations_url":"https://api.github.com/users/HughParsonage/orgs","repos_url":"https://api.github.com/users/HughParsonage/repos","events_url":"https://api.github.com/users/HughParsonage/events{/privacy}","received_events_url":"https://api.github.com/users/HughParsonage/received_events","type":"User","site_admin":false},"labels":[{"id":105265381,"url":"https://api.github.com/repos/Rdatatable/data.table/labels/bug","name":"bug","color":"DF3A2C","default":true},{"id":256384883,"url":"https://api.github.com/repos/Rdatatable/data.table/labels/fread","name":"fread","color":"207de5","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-09-21T15:24:52Z","updated_at":"2017-11-21T23:17:47Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"When leading whitespace is present in the first column (or the only column) and `strip.white = FALSE`, the leading whitespace is nonetheless trimmed.\r\n\r\n```r\r\nfread(input = \"ab,x\\n  cd,x \", sep = \",\", strip.white = FALSE, header = FALSE)\r\n#    V1 V2\r\n# 1: ab  x\r\n# 2: cd x \r\n# Expected\r\n#       V1 V2\r\n# 1:   ab  x\r\n# 2:   cd x  \r\n```\r\n\r\nLeading whitespace is correctly retained when present in other columns:\r\n\r\n```r\r\nfread(input = \"y,ab,x\\ny,  cd,x \", sep = \",\", strip.white = FALSE, header = FALSE)\r\n# OK\r\n#    V1   V2 V3\r\n# 1:  y   ab  x\r\n# 2:  y   cd x\r\n\r\n# Compared with no whitespace\r\nfread(input = \"y,ab,x\\ny,cd,x \", sep = \",\", strip.white = FALSE, header = FALSE)\r\n#    V1 V2 V3\r\n# 1:  y ab  x\r\n# 2:  y cd x \r\n```\r\n\r\n\r\n## Session info and verbose output\r\nN.B. I did not test against the most recent build as it was failing at the time I found this issue. My dev version of `data.table` is only a couple of weeks old.\r\n\r\n### `sessionInfo()`\r\n```\r\n> sessionInfo()\r\nR version 3.4.1 (2017-06-30)\r\nPlatform: x86_64-w64-mingw32/x64 (64-bit)\r\nRunning under: Windows >= 8 x64 (build 9200)\r\n\r\nMatrix products: default\r\n\r\nlocale:\r\n[1] LC_COLLATE=English_Australia.1252  LC_CTYPE=English_Australia.1252   \r\n[3] LC_MONETARY=English_Australia.1252 LC_NUMERIC=C                      \r\n[5] LC_TIME=English_Australia.1252    \r\n\r\nattached base packages:\r\n[1] stats     graphics  grDevices utils     datasets  methods   base     \r\n\r\nother attached packages:\r\n[1] data.table_1.10.5    RevoUtilsMath_10.0.0\r\n\r\nloaded via a namespace (and not attached):\r\n[1] compiler_3.4.1   RevoUtils_10.0.5 tools_3.4.1   \r\n```\r\n### `fread(verbose = TRUE)`\r\n```\r\n> library(data.table)\r\ndata.table 1.10.5 IN DEVELOPMENT built 2017-09-06 01:46:07 UTC; travis\r\n  The fastest way to learn (by data.table authors): https://www.datacamp.com/courses/data-analysis-the-data-table-way\r\n  Documentation: ?data.table, example(data.table) and browseVignettes(\"data.table\")\r\n  Release notes, videos and slides: http://r-datatable.com\r\n\r\n> fread(\"ab,x\\n cd,x\", sep = \",\", strip.white = FALSE, header = FALSE, verbose = TRUE)\r\nInput contains a \\n (or is \"\"). Taking this to be text input (not a filename)\r\n[1] Check arguments\r\n  Using 12 threads (omp_get_max_threads()=12, nth=12)\r\n  NAstrings = [<<NA>>]\r\n  None of the NAstrings look like numbers.\r\n  show progress = 1\r\n[2] Opening the file\r\n`input` argument is given, interpreting as raw text to read\r\n[3] Detect and skip BOM\r\n[4] Detect end-of-line character(s)\r\n  Detected eol as \\n only, the UNIX and Mac standard.\r\n[6] Skipping initial rows if needed\r\n  Positioned on line 1 starting: <<ab,x>>\r\n[7] Detect separator, quoting rule, and ncolumns\r\n  Using supplied sep ','\r\n  sep=','  with 2 lines of 2 fields using quote rule 0\r\n  Detected 2 columns on line 1. This line is either column names or first data row. Line starts as: <<ab,x>>\r\n  Quote rule picked = 0\r\n[8] Determine column names\r\n  'header' changed by user from 'auto' to false\r\n[9] Detect column types\r\n  Number of sampling jump points = 1 because (10 bytes from row 1 to eof) / (2 * 10 jump0size) == 0\r\n  Type codes (jump 000)    : 66  Quote rule 0\r\n  =====\r\n  Sampled 2 rows (handled \\n inside quoted fields) at 1 jump points\r\n  Bytes from first data row on line 1 to the end of last row: 10\r\n  Line length: mean=5.00 sd=0.00 min=5 max=5\r\n  Estimated number of rows: 10 / 5.00 = 2\r\n  Initial alloc = 2 rows (2 + 0%) using bytes/max(mean-2*sd,min) clamped between [1.1*estn, 2.0*estn]\r\n  All rows were sampled since file is small so we know nrow=2 exactly\r\n  =====\r\n[10] Apply user overrides on column types\r\nAfter 0 type and 0 drop user overrides : 66\r\n[11] Allocate memory for the datatable\r\n  Allocating 2 column slots (2 - 0 dropped) with 2 rows\r\n[12] Read the data\r\n[13] Finalizing the datatable\r\nRead 2 rows x 2 columns from 10 bytes file in 00:00.001 wall clock time\r\nThread buffers were grown 0 times (if all 1 threads each grew once, this figure would be 1)\r\nFinal type counts\r\n         0 : drop     \r\n         0 : bool8    \r\n         0 : int32    \r\n         0 : int32    \r\n         0 : int64    \r\n         0 : float64  \r\n         2 : string   \r\nRead 2 rows. Exactly what was estimated and allocated up front\r\n=============================\r\n   0.000s (  0%) Memory map 0.000GB file\r\n   0.000s (  0%) sep=',' ncol=2 and header detection\r\n   0.000s (  0%) Column type detection using 2 sample rows\r\n   0.000s (  0%) Allocation of 2 rows x 2 cols (0.000GB)\r\n   0.001s (100%) Reading 1 chunks of 1.000MB (209715 rows) using 1 threads\r\n   =    0.000s (  0%) Finding first non-embedded \\n after each jump\r\n   +    0.000s (  0%) Parse to row-major thread buffers\r\n   +    0.000s (  0%) Transpose\r\n   +    0.001s (100%) Waiting\r\n   0.000s (  0%) Rereading 0 columns due to out-of-sample type exceptions\r\n   0.001s        Total\r\n   V1 V2\r\n1: ab  x\r\n2: cd  x\r\n```\r\n\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/Rdatatable/data.table/issues/comments/346192842","html_url":"https://github.com/Rdatatable/data.table/issues/2376#issuecomment-346192842","issue_url":"https://api.github.com/repos/Rdatatable/data.table/issues/2376","id":346192842,"user":{"login":"HughParsonage","id":8111628,"avatar_url":"https://avatars1.githubusercontent.com/u/8111628?v=4","gravatar_id":"","url":"https://api.github.com/users/HughParsonage","html_url":"https://github.com/HughParsonage","followers_url":"https://api.github.com/users/HughParsonage/followers","following_url":"https://api.github.com/users/HughParsonage/following{/other_user}","gists_url":"https://api.github.com/users/HughParsonage/gists{/gist_id}","starred_url":"https://api.github.com/users/HughParsonage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HughParsonage/subscriptions","organizations_url":"https://api.github.com/users/HughParsonage/orgs","repos_url":"https://api.github.com/users/HughParsonage/repos","events_url":"https://api.github.com/users/HughParsonage/events{/privacy}","received_events_url":"https://api.github.com/users/HughParsonage/received_events","type":"User","site_admin":false},"created_at":"2017-11-21T23:17:47Z","updated_at":"2017-11-21T23:17:47Z","author_association":"CONTRIBUTOR","body":"Confirm the fix. Maybe something related to the `sep=NULL` feature?"}}
{"actor":{"display_login":"HughParsonage"}}