title: how to print out snippets of a RDD in the spark-shell / pyspark?
body: <p>When working in the spark-shell, I frequently want to inspect RDDs (similar to using <code>head</code> in unix).</p>
  
  <p>For example:</p>
  
  <pre><code>scala&gt; val readmeFile = sc.textFile("input/tmp/README.md")
  scala&gt; // how to inspect the readmeFile?
  </code></pre>
  
  <p>and ...</p>
  
  <pre><code>scala&gt; val linesContainingSpark = readmeFile.filter(line =&gt; line.contains("Spark"))
  scala&gt; // how to inspect linesContainingSpark?
  </code></pre>