thanks all
this my 1st script it counts all the numbers in the past result from an csv file and finds the top 20 below is the output from the script
number count
37 6
51 5
6 5
10 4
3 4
55 4
52 4
72 4
63 4
73 4
38 4
44 4
24 4
25 3
9 3
64 3
21 3
45 3
7 3
34 3
the top 20 numbers are: 37 51 6 10 3 55 52 72 63 73 38 44 24 25 9 64 21 45 7 34
the format of csv file should look like below :
10 |
24 |
51 |
44 |
4 |
74 |
77 |
62 |
14 |
69 |
26 |
6 |
11 |
40 |
13 |
12 |
52 |
75 |
68 |
37 |
80 |
53 |
57 |
24 |
65 |
40 |
79 |
76 |
48 |
29 |
8 |
37 |
61 |
3 |
73 |
4 |
30 |
66 |
59 |
41 |
23 |
68 |
53 |
20 |
21 |
29 |
19 |
45 |
32 |
6 |
70 |
26 |
44 |
25 |
55 |
48 |
37 |
9 |
64 |
3 |
72 |
6 |
26 |
55 |
15 |
45 |
44 |
16 |
47 |
3 |
43 |
34 |
79 |
7 |
67 |
29 |
69 |
50 |
51 |
54 |
43 |
31 |
1 |
37 |
49 |
12 |
27 |
20 |
25 |
8 |
42 |
36 |
7 |
4 |
73 |
61 |
21 |
80 |
51 |
56 |
72 |
5 |
31 |
10 |
32 |
64 |
63 |
53 |
36 |
54 |
19 |
65 |
50 |
28 |
24 |
47 |
27 |
49 |
34 |
51 |
73 |
75 |
3 |
50 |
14 |
38 |
37 |
1 |
2 |
22 |
74 |
63 |
9 |
24 |
5 |
56 |
69 |
16 |
10 |
45 |
44 |
70 |
52 |
51 |
20 |
61 |
59 |
38 |
64 |
12 |
28 |
21 |
30 |
57 |
78 |
68 |
55 |
6 |
63 |
5 |
6 |
25 |
18 |
14 |
47 |
73 |
72 |
62 |
11 |
7 |
23 |
75 |
79 |
9 |
77 |
38 |
8 |
33 |
46 |
52 |
63 |
37 |
17 |
80 |
34 |
28 |
10 |
77 |
38 |
31 |
46 |
67 |
78 |
36 |
2 |
52 |
72 |
1 |
55 |
22 |
the powershell code:
__________________________________________________________________________________________________________________________
$topnumbers = 20 # find the top 20 numbers you can chage this
$file = "c:\windows\temp\Results_24092019.csv" # the past result lotto numbers
Remove-Item –path "c:\windows\temp\count1.csv" -Recurse -Force -ErrorAction SilentlyContinue
write-host "number count "
gc $file | ForEach-Object {$_.split(',')} | group-object | sort-object -Property "Count" -Descending | select -First $topnumbers |Select-Object| ft -HideTableHeaders -auto -Property ("Name", "Count")
gc $file| ForEach-Object {$_.split(',')} | group-object | sort-object -Property "Count" -Descending |Select-Object | ft -HideTableHeaders ("Name") |Out-File -Append -FilePath c:\windows\temp\count1.csv -Encoding OEM
$sr = gc "c:\windows\temp\count1.csv"
$tr= ($sr)-join (",")
$tr1= $tr-replace '\s+', ''
$tr2 = $tr1.Substring(0,$tr1.Length-1).TrimStart(',').TrimEnd(',') | ForEach-Object {($_.Split(","))} | select -First $topnumbers
$tr21 =($tr2.Split(" ")| foreach {[int]$_ } | sort ) -join (",")
write-host "the top $topnumbers numbers are: $tr2"
write-host "______________________________________________________________________________________________________________________________________"
#write-host $tr3
pause