title: Spark - Word count test
body: <p>I only want to count words in spark (pyspark),  but I can either map the letters or the whole string.</p>
  
  <p>I tried: 
  (whole string) </p>
  
  <pre><code>v1='Hi hi hi bye bye bye word count' 
  v1_temp=sc.parallelize([v1]) 
  v1_map = v1_temp.flatMap(lambda x: x.split('\t'))
  v1_counts = v1_map.map(lambda x: (x, 1))
  v1_counts.collect()  
  </code></pre>
  
  <p>or (just letters) </p>
  
  <pre><code>v1='Hi hi hi bye bye bye word count'
  v1_temp=sc.parallelize(v1)
  v1_map = v1_temp.flatMap(lambda x: x.split('\t'))
  v1_counts = v1_map.map(lambda x: (x, 1))
  v1_counts.collect()
  </code></pre>