title: Reading data from a compressed CSV file in raw format directly into memory?
body: <h2>The Question:</h2>
  <p>I have a dataset that I am pulling from an S3 bucket that is stored in a compressed CSV file format. The data comes via the S3 API as a raw vector which I then save as a file and then read the data in from that file.</p>
  <p>Is there a way that I can just read the data directly from the raw vector without having to write these temporary files?</p>
  <h2>Current code:</h2>
  <pre><code># Import packages -------------------------------------------------------------
  library(paws)
  
  # Set up S3 access ------------------------------------------------------------
  s3 &lt;- paws::s3()
  aws_s3_bucket &lt;- Sys.getenv(&quot;AWS_S3_BUCKET&quot;)
  
  # Fetch dataset from S3 which returns a raw vector ----------------------------
  s3_object &lt;- s3$get_object(Bucket = aws_s3_bucket, Key = &quot;data.csv.gz&quot;)
  s3_object_body &lt;- s3_object$Body
  
  # Write the raw vector to a temporary file (This is what I want to remove) ----
  file_name &lt;- &quot;s3_files/mydataset.csv.gz&quot;
  if (file.exists(file_name)) { unlink(file_name) }
  writeBin(s3_object_body, con = file_name)
  
  # Finally, read the data from the file ----------------------------------------
  data &lt;- data.table::fread(file_name)
  </code></pre>
  <h2>Some attempts that haven't worked:</h2>
  <p>Trying <code>readr::read_csv(s3_object_body)</code> results in the following error:</p>
  <pre><code>Error in vroom_(file, delim = delim %||% col_types$delim, col_names = col_names,  : 
    embedded nul in string: '\037&lt;U+008B&gt;\b\b&lt;f1&gt;7\aa\002&lt;ff&gt;data.csv'
  </code></pre>
  <p>Trying <code>iotools::read.csv.raw(s3_object_body)</code> results in the following error:</p>
  <pre><code>Error in isOpen(con, &quot;rb&quot;) : unimplemented type 'raw' in 'asInteger'
  </code></pre>