Merging two elements from column of a file and counting them in c#
<p>My file is:<br>
  outlook temperature Humidity  Windy  PlayTennis
    sunny      hot        high     false   N
    sunny      hot        high     true    N
    overcast   hot        high     false   P
    rain       mild       high     false   P
    rain       cool       normal   false   P</p>

<p>I found out unique elements from file as:
element:occurence
suny :2
overcast:1
rain:2
mild:1
cool:1
hot :4
normal:1
high:2
false:4
true:1
n:2
p:3</p>

<p>Then I removed elements whose occurence was less than 1.</p>

<p>aso output came as:
    suny : 2
    rain: 2
    hot :3
    high:4
    false:4
    n:2
    p:3</p>

<p>Now i want output as( from the first output, it should loop with every other element to make a set of two frequent set)</p>

<pre><code>element:occurence

sunny,hot:2
sunny,high:2
sunny,false:1
sunny,n:2
sunny,p:0
rain,hot:0
rain,high:1
rain,false:2
rain,n:0
rain,p:2
hot,high:2
hot,false:1
hot,n:2
hot,p:0
and so on..
</code></pre>

<p>Here is my code:</p>

<pre><code>var occurences = File.ReadAllLines(file)
    .Skip(1)
    .SelectMany(l =&gt; l.Split(new []{' '},StringSplitOptions.RemoveEmptyEntries))
    .GroupBy(w =&gt; w)
    .ToDictionary(g =&gt; g.Key, g =&gt; g.Count());

foreach(var pair in occurences)
    label1.Text += String.Format("{0}: {1}\n", pair.Key, pair.Value);
</code></pre>

<p>I implemented this to find the 1st frequent set.</p>

<p>For 2nd one. what should I do?</p>

<p>I also need to find the third set.</p>

<p>I am new to c#. Please help me.</p>
