{
  "id": 5673,
  "title": "How to import 2.19 GB data in R in low configuration machine ? ",
  "url": "/competitions/expedia-personalized-sort/discussion/5673",
  "author_name": "",
  "post_date": "2013-09-06T06:30:30.647Z",
  "votes": null,
  "comment_count": 4,
  "views": 5762,
  "content": "<p>Windows 7 , 4 - 8 GB RAM , 2.2 GHz, Dual Core &nbsp;taking infinite to import .</p>\n<p>Any suggestion on how to manager the import in chunks or method to overcome if using low configuration machine.&nbsp;</p>\n<p>Takes infinite for importing how much it will for predicting. :).&nbsp;</p>\n<p>&nbsp;</p>\n<p>Thanks !</p>",
  "messages": [
    {
      "id": "30279",
      "postDate": "09/06/2013 06:30:30",
      "content": "<p>Windows 7 , 4 - 8 GB RAM , 2.2 GHz, Dual Core &nbsp;taking infinite to import .</p>\n<p>Any suggestion on how to manager the import in chunks or method to overcome if using low configuration machine.&nbsp;</p>\n<p>Takes infinite for importing how much it will for predicting. :).&nbsp;</p>\n<p>&nbsp;</p>\n<p>Thanks !</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "30281",
      "postDate": "09/06/2013 06:42:55",
      "content": "<p>Use fread() in the data.table package.</p>\n<p>&nbsp;</p>\n<p>See benchmarks (and further alternatives) here:&nbsp;http://stackoverflow.com/questions/1727772/quickly-reading-very-large-tables-as-dataframes-in-r</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "30397",
      "postDate": "09/07/2013 02:00:11",
      "content": "<p>Yogesh: I used the following code:</p>\n<p><br>memory.limit(1E8)</p>\n<p>#I will igonore for the moment time of day</p>\n<p>dateconv=setClass(&quot;dateconv&quot;)</p>\n<p>setAs(&quot;character&quot;,&quot;dateconv&quot;, function(from) as.numeric(as.Date(from, format=&quot;%Y-%m-%d %H:%M:%S&quot;) ) )</p>\n<p>#NA coded as NULL . Read a little bit (200)</p>\n<p>train &lt;- read.csv(&quot;train.csv&quot;, header=TRUE, nrows=200,sep = &quot;,&quot;, quote=&quot;\\&quot;&quot;, dec=&quot;.&quot;,na.strings=&quot;NULL&quot;)</p>\n<p>classes = sapply(train,class)</p>\n<p># I change logical variables to integer -not needed</p>\n<p>classes[classes==&quot;logical&quot;]&lt;- &quot;integer&quot;</p>\n<p># train</p>\n<p>classes[c(5, 6, 10, 12, 13, 14, 16, 25, 26, 30, 33, 36, 39, 42, 45, 48, 51, 53)]=&quot;numeric&quot;</p>\n<p>#test</p>\n<p># classes[c(5, 6,10, 12, 13, 14, 15, 24, 25, 29, 32, 35, 38, 41, 44, 47, 50)]=&quot;numeric&quot;</p>\n<p>classes[2] &lt;- &quot;dateconv&quot;</p>\n<p>#Read all</p>\n<p>train &lt;- read.csv(&quot;train.csv&quot;, header=TRUE, colClasses=classes,sep = &quot;,&quot;, quote=&quot;\\&quot;&quot;, dec=&quot;.&quot;,na.strings=&quot;NULL&quot;)</p>\n<p>object.size(train)</p>\n<p># 2816585496 bytes</p>\n<p>dim(train)</p>\n<p># 9917530 54</p>\n<p>&nbsp;</p>\n<p>It takes some minutes to read it. After import and saving. my machine almost fainted. Be sure that you have enough virtual memory. If you save the session with train data, the size of file is ca, 193500KB</p>\n<p>I hope it Works for you too.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "31062",
      "postDate": "09/17/2013 21:26:58",
      "content": "<p>If you don't want to overload your pc you can always use a postgres database for data storage and use the RODBC package in R to query parts of the data with SQL syntax.</p>\n<p>Below 2 sql files to import train.csv and test.csv into postgres.</p>\n<p>&nbsp;</p>\n<p>&nbsp;</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "31316",
      "postDate": "09/21/2013 20:36:38",
      "content": "<p>[quote=Yogesh;30279]</p>\n<p>Windows 7 , 4 - 8 GB RAM , 2.2 GHz, Dual Core &nbsp;taking infinite to import .</p>\n<p>Any suggestion on how to manager the import in chunks or method to overcome if using low configuration machine.&nbsp;</p>\n<p>Takes infinite for importing how much it will for predicting. :).&nbsp;</p>\n<p>&nbsp;</p>\n<p>Thanks !</p>\n<p>[/quote]</p>\n<p>Hi below code I used to read 7 GB of Facebook competition data.</p>\n<p>&nbsp;</p>\n<p>library(ff)</p>\n<p>train &lt;- read.csv.ffdf(file=&quot;Train.csv&quot;,header=TRUE,VERBOSE=TRUE,first.rows=100000,next.rows=100000,colClasses=NA)</p>\n<p>&nbsp;</p>\n<p>It took 37 min to read the file in R</p>\n<p>I used same code to read Expedia data also. I think it took 15-20 min (don't remember exactly). It won't consume more than 4 GB of RAM (may work in 3 GB of RAM also)</p>",
      "rawMarkdown": "",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 30281,
      "author_name": "mm247601",
      "author_url": "",
      "post_date": "09/06/2013 06:42:55",
      "content": "<p>Use fread() in the data.table package.</p>\n<p>&nbsp;</p>\n<p>See benchmarks (and further alternatives) here:&nbsp;http://stackoverflow.com/questions/1727772/quickly-reading-very-large-tables-as-dataframes-in-r</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 30397,
      "author_name": "gmobaz",
      "author_url": "",
      "post_date": "09/07/2013 02:00:11",
      "content": "<p>Yogesh: I used the following code:</p>\n<p><br>memory.limit(1E8)</p>\n<p>#I will igonore for the moment time of day</p>\n<p>dateconv=setClass(&quot;dateconv&quot;)</p>\n<p>setAs(&quot;character&quot;,&quot;dateconv&quot;, function(from) as.numeric(as.Date(from, format=&quot;%Y-%m-%d %H:%M:%S&quot;) ) )</p>\n<p>#NA coded as NULL . Read a little bit (200)</p>\n<p>train &lt;- read.csv(&quot;train.csv&quot;, header=TRUE, nrows=200,sep = &quot;,&quot;, quote=&quot;\\&quot;&quot;, dec=&quot;.&quot;,na.strings=&quot;NULL&quot;)</p>\n<p>classes = sapply(train,class)</p>\n<p># I change logical variables to integer -not needed</p>\n<p>classes[classes==&quot;logical&quot;]&lt;- &quot;integer&quot;</p>\n<p># train</p>\n<p>classes[c(5, 6, 10, 12, 13, 14, 16, 25, 26, 30, 33, 36, 39, 42, 45, 48, 51, 53)]=&quot;numeric&quot;</p>\n<p>#test</p>\n<p># classes[c(5, 6,10, 12, 13, 14, 15, 24, 25, 29, 32, 35, 38, 41, 44, 47, 50)]=&quot;numeric&quot;</p>\n<p>classes[2] &lt;- &quot;dateconv&quot;</p>\n<p>#Read all</p>\n<p>train &lt;- read.csv(&quot;train.csv&quot;, header=TRUE, colClasses=classes,sep = &quot;,&quot;, quote=&quot;\\&quot;&quot;, dec=&quot;.&quot;,na.strings=&quot;NULL&quot;)</p>\n<p>object.size(train)</p>\n<p># 2816585496 bytes</p>\n<p>dim(train)</p>\n<p># 9917530 54</p>\n<p>&nbsp;</p>\n<p>It takes some minutes to read it. After import and saving. my machine almost fainted. Be sure that you have enough virtual memory. If you save the session with train data, the size of file is ca, 193500KB</p>\n<p>I hope it Works for you too.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 31062,
      "author_name": "mennotaanman",
      "author_url": "",
      "post_date": "09/17/2013 21:26:58",
      "content": "<p>If you don't want to overload your pc you can always use a postgres database for data storage and use the RODBC package in R to query parts of the data with SQL syntax.</p>\n<p>Below 2 sql files to import train.csv and test.csv into postgres.</p>\n<p>&nbsp;</p>\n<p>&nbsp;</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 31316,
      "author_name": "thakurrajanand",
      "author_url": "",
      "post_date": "09/21/2013 20:36:38",
      "content": "<p>[quote=Yogesh;30279]</p>\n<p>Windows 7 , 4 - 8 GB RAM , 2.2 GHz, Dual Core &nbsp;taking infinite to import .</p>\n<p>Any suggestion on how to manager the import in chunks or method to overcome if using low configuration machine.&nbsp;</p>\n<p>Takes infinite for importing how much it will for predicting. :).&nbsp;</p>\n<p>&nbsp;</p>\n<p>Thanks !</p>\n<p>[/quote]</p>\n<p>Hi below code I used to read 7 GB of Facebook competition data.</p>\n<p>&nbsp;</p>\n<p>library(ff)</p>\n<p>train &lt;- read.csv.ffdf(file=&quot;Train.csv&quot;,header=TRUE,VERBOSE=TRUE,first.rows=100000,next.rows=100000,colClasses=NA)</p>\n<p>&nbsp;</p>\n<p>It took 37 min to read the file in R</p>\n<p>I used same code to read Expedia data also. I think it took 15-20 min (don't remember exactly). It won't consume more than 4 GB of RAM (may work in 3 GB of RAM also)</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "30279": "",
    "30281": "",
    "30397": "",
    "31062": "",
    "31316": ""
  },
  "source": "meta"
}