title: how can I optimize schema inference on a remote file for CSV with Spark
body: <p>I have a remote file in S3 (or other) and I need the schema of the file.
  I did not find an option to sample the data as for JSON (<code>e.g. read.option("samplingRation", 0.25)</code>).</p>
  
  <p>Is there a way to optimize the reading of the schema?</p>
  
  <p>Spark reads the entire CSV file over the network before returning the inferred schema. For large files this can take quite a long time.</p>
  
  <p><code>.option("samplingRatio", samplingRatioVal)</code> does not work on csv</p>