I'm not trying to do anything fancy just select a column from an xlsx file as a variable. Well what I am trying to do overall is to take a list of numbers from a column and count the occurrences. I have two columns of numbers and want to count them seperately.
I am new to JS and all that I just wanted something that I thought would be easy to start with. Here is the code I have so far.
var xlsx = require("xlsx");
var numbersWB = xlsx.readFile('lucky_for_life_numbers.xlsx');//imports the file
var ws = numbersWB.Sheets['Drawn'];//gets the Sheet 'Drawn' for the drawn numbers
var data = xlsx.utils.sheet_to_json(ws);//converts the drawn column to something readable
console.log(data)//displays the data
And here is some sample data.
[
{ numbers: '6 - 8 - 14 - 25 - 42', lucky_numbers: 6 },
{ numbers: '1 - 12 - 17 - 28 - 44', lucky_numbers: 14 },
{ numbers: '1 - 10 - 24 - 26 - 30', lucky_numbers: 9 },
{ numbers: '5 - 23 - 26 - 29 - 36', lucky_numbers: 10 },
{ numbers: '8 - 15 - 19 - 46 - 47', lucky_numbers: 18 },
{ numbers: '2 - 6 - 24 - 32 - 39', lucky_numbers: 11 },
{ numbers: '4 - 5 - 35 - 37 - 48', lucky_numbers: 2 },
// ... 1319 more items
]
It's just like the power ball lottery - choose 5 numbers and a lucky number.
I have the data in an Excel spreadsheet and was looking to count the occurrences of the numbers by column, or lowest number to highest. For example:
Column 1 1:2 ,2:1, 4:1, 5:1, 6:1, 8:1
Column 2 5:1, 6:1, 8:1......
lucky numbers 2:1, 6:1, 9:1.......
And so on
The 'numbers:' is a column and the 'lucky_numbers:' is a separate column in the spreadsheet but, this is how they are formatted as json data.
Here is a sample of the excel data
I didn't think it was going to be so hard to get this down. I did a little something like this in python and had pandas to help with all of the fun stuff.
Any help would be appreciated. Thanks, and have a great day.