title: How to filter data based on three columns in Scala
body: <p>I am a newbie to scala and I want to iterate through three for loos for one data set and perform some analysis.For example my data is like below:</p>
  
  <pre><code>Sample.csv
  
  1,100,0,NA,0,1,0,Friday,1,5
  1,100,0,NA,0,1,0,Wednesday,1,9
  1,100,1,NA,0,1,0,Friday,1,5
  1,100,2,NA,0,1,0,Friday,1,5
  1,101,0,NA,0,1,0,Friday,1,5
  1,101,1,NA,0,1,0,Friday,1,5
  1,101,2,NA,0,1,0,Friday,1,5
  1,102,0,NA,0,1,0,Friday,1,5
  1,102,1,NA,0,1,0,Friday,1,5
  1,102,2,NA,0,1,0,Friday,1,5
  </code></pre>
  
  <p>So now I read the like below:</p>
  
  <pre><code>val data = sc.textFile("C:/users/ricky/Data.csv")
  </code></pre>
  
  <p>Now I need to implement a filter for first three columns in scala to filter the subset of the whole data and do some analysis.For example  The first three columns are the columns to be filtered. So I have one value for 1st column (1),3 values for second column (100,101,102) and 3 values for third column (0,1,2).So now I need to run the filter to provide subset of the whole data as .Is it good to use loops like below</p>
  
  <pre><code>for {
    i &lt;- 1
    j &lt;- 100 to 102
    k &lt;- 1 to 2
  }
  </code></pre>
  
  <p>which should need subset data like </p>
  
  <pre><code>1,100,0,NA,0,1,0,Friday,1,5
  1,100,0,NA,0,1,0,Wednesday,1,9
  
  where i=1 ,j=100,and k=0
  </code></pre>
  
  <p>and up to </p>
  
  <pre><code>1,102,2,NA,0,1,0,Friday,1,5
  
  where i=1 ,j=102,and k=2
  </code></pre>
  
  <p>How can I run for the data (which I read from CSV) in Scala.</p>