Dissecting a CSV file

I have a performance report exported in csv format that I want to import into my web app. The data is presented in the following format:

Staff Performance by day
Bridge Street
Abbi Clarke
Date Services Courses Products Hours Worked
EX Vat Total Ex Vat Total Ex Vat Total Hours Minutes
02/01/2019 0.00 0.00 0.30 3.50 17.90 22.90 9 0
03/01/2019 0.00 0.00 0.30 3.50 17.90 22.90 9 0
04/01/2019 0.00 0.00 0.30 3.50 17.90 22.90 9 0
Adam Carter
Date Services Courses Products Hours Worked
EX Vat Total Ex Vat Total Ex Vat Total Hours Minutes
02/01/2019 0.00 0.00 0.30 3.50 17.90 22.90 9 0
03/01/2019 0.00 0.00 0.30 3.50 17.90 22.90 9 0
04/01/2019 0.00 0.00 0.30 3.50 17.90 22.90 9 0
James Sharpe
Date Services Courses Products Hours Worked
EX Vat Total Ex Vat Total Ex Vat Total Hours Minutes
02/01/2019 0.00 0.00 0.30 3.50 17.90 22.90 9 0
03/01/2019 0.00 0.00 0.30 3.50 17.90 22.90 9 0
04/01/2019 0.00 0.00 0.30 3.50 17.90 22.90 9 0

I’d like to have each team members data separated out into a slice of maps []map[string][]string with the team member name as the key and the figures as a slice of string - ignoring all the other stuff.

This would allow me to loop through each map using the encoding/csv package so I can upload it to my database.

How do I approach reading in the document this way?

Some questions:

  • How do you identify the name of a team member?
  • How do you identify “the figures” for a team member?
  • What would be the expected []map[string][]string result the data from your question?
  • What have you already tried?
  • Does it work?
  • If not, what does not work?

• Each team member is the persons name.
• The data that follows (the rows starting with the date) are the figures.
• I would like each team members subset of data to be stored in the map with the team member name as the key.
• My current workaround is to manually separate the data into a separate CSV file for each team member’s data - I use the team member name as the file name. I then read each file with the encoding/csv package.

I’m fairly new to Go (and programming in general) - I’ve scoured the forums trying to find a solution but still no luck! Any help would be appreciated.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.