title: How to import a very large file into R (separate by comma)
body: <p>I have an <code>xls</code> file that contains over a million rows of data.  Everything is in one column and separated by commas. It takes a very long time for Excel to open it, and all I need is two pieces of information - customer ID and transaction amount.</p>
  <p>My approach is to import the file into R (separate by comma), then extract the two columns I need. The problem is that everything is still in one column after importing. I have tried <code>read.csv(file, sep = &quot;,&quot;)</code> and <code>read_csv(file, col_names = T)</code> from <code>readr</code>. None worked. However, I saved the first five rows as another <code>xls</code> file for testing, and it imports fine (correctly separated) without any issue.</p>
  <p>I also tried <code>cSplit</code> to split the imported dataset by comma, but I got the <code>Error: C stack usage 14478558 is too close to the limit</code>. I guess it's due to the file size. I'm sorry that I can't provide a replicable example, but the data looks like below with one million rows:</p>
  <pre><code>  customer_id,type,note_number,amount,company
    1,cc,abc,5,A
    2,dc,bcd,7,B
    3,cc,cde,10,C
  </code></pre>
  <p><strong>Edit</strong></p>
  <p>Thanks to @akrun for suggesting <code>data.table::fread(file)</code>,  the warning message from the function made me realize that some fields contain <code>,</code> inside <code>&quot;&quot;</code> in the source file. What makes it more tricky to import and separate is that some have several <code>&quot;&quot;</code>. For example, someone's name can show up as <code>&quot;&quot;Joh, Dep&quot;&quot;</code> instead of <code>&quot;Joh Dep&quot;</code>.</p>
  <p>Also, as @RonakShah suggested, I created a <a href="https://drive.google.com/file/d/14iBSvz-lTRa5QXFgCfVYzAqlJNigwsQg/view?usp=sharing" rel="nofollow noreferrer">sample test file</a>.</p>