cancel
Showing results for 
Search instead for 
Did you mean: 
megan_mcp
Community Manager Community Manager
Community Manager

Hi everyone! This week I wanted to try something a little more challenging but I’m going to need a bit of help completing it. Below I have attached a text file containing the goals scored during the World Cup. The data is formatted as;

                        Player;country;time;

Time represents the minute in the game the goal was scored.

With this data we can produce a lot of different statistics for example;

  • Total number of goals scored by a given country
  • Total number of goals scored by a given player
  • List the name of all the players who scored for a given country
  • Total number of goals by all countries
  • Total number of goals scored during the first half (45 minutes)
  • Total number of goals scored during the second half (45 minutes to 90 minutes)
  • Total number of goals scored during extra time (after 90 minutes of play)

For now I just want to focus on the first bullet point.

First I thought it would be ideal to transform the data to table format, then simply count the rows of the country selected;

q)data:flip`player`country`minute!("SSS";";")0:`:goals.txt
q)count select from data where country=`Spain
7

I also wanted to loop through the text file and print (player + “ from “ + country + “ scored a goal at the “ + minute + “ th minute”) for each player. Which seemed easy at first but really had difficulty.

I reckoned a function was most definitely needed but couldn’t wrap my head around how to loop not only through the 3 items but then onto the rest of the list.

Any help / advice would be greatly appreciated !!

Megan

3 Comments
Contributors