[CODE] add speaker from CSV

This commit is contained in:
Jannik Beyerstedt 2018-11-25 15:44:03 +01:00
parent e5b29648c0
commit 6036936df4
2 changed files with 23 additions and 18 deletions

13
main.go
View File

@ -97,8 +97,6 @@ func main() {
// omit title row
csvRecords := records[1:]
// fmt.Println(csvRecords) // TODO
/*
* Data Conversion
*/
@ -144,11 +142,10 @@ func main() {
// convert csv entries into event and sort in days
events := make(map[int][]event) // map of day index to day's events
eventID := 100
speakerID := 1
confDays := make(map[int]day) // map of day index to day structure
for idx, row := range csvRecords {
// TODO: add speakers
eventStart, err := time.ParseInLocation(timeCSVFormat, row[csvColStart], loc)
if err != nil {
log.Fatal("Error parsing start date in CSV file, line ", idx+1, ":\n", err)
@ -158,13 +155,19 @@ func main() {
log.Fatal("Error parsing end date in CSV file, line ", idx+1, ":\n", err)
}
// create event struct and sort into day map
var eventSpeaker []person
if row[csvColSpeaker] != "" {
eventSpeaker = append(eventSpeaker, person{speakerID, row[csvColSpeaker]})
}
dayIdx := int(eventStart.Sub(conferenceStart).Hours()/24) + 1
eventGUID := strconv.Itoa(dayIdx) + "-" + strconv.Itoa(eventID)
eventDateStr := eventStart.Format(time.RFC3339)
eventStartStr := eventStart.Format(timeXMLTimeFormat)
eventDurationStr := fmtDuration(eventEnd.Sub(eventStart))
events[dayIdx] = append(events[dayIdx], event{eventID, eventGUID, row[csvColRoom], row[csvColTitle], eventDateStr, eventStartStr, eventDurationStr, row[csvColLang], nil})
events[dayIdx] = append(events[dayIdx], event{eventID, eventGUID, row[csvColRoom], row[csvColTitle], eventDateStr, eventStartStr, eventDurationStr, row[csvColLang], eventSpeaker})
// create days
if _, ok := confDays[dayIdx]; !ok {

View File

@ -1,14 +1,16 @@
Titel des Programmpunktes;Raum;Von (TT.MM.JJ HH:MM);Bis (TT.MM.JJ HH:MM);Vortragende;Sprache (DE/EN)
Begrüßung;Holzhafen;25.11.18 12:00;25.11.18 13:00;Ada Lovelace;EN
Vortrag 1;Raackmoor;25.11.18 12:00;25.11.18 13:00;Marie Curie;
Noch ein Vortrag;Wohldorfer Wald;25.11.18 12:00;25.11.18 13:00;Donna Strickland;
Workshop;Heuckenlock;25.11.18 12:00;25.11.18 13:00;Edith Clarke;
Testvortrag Ebbe;Heuckenlock Ebbe;25.11.18 12:00;25.11.18 13:00;Bjarne Stroustrup;
Testvortrag Flut;Heuckenlock Flut;25.11.18 12:00;25.11.18 13:00;Chris Lattner;
Test 1;Holzhafen;25.11.18 13:00;25.11.18 13:30;;
Test 2;Raackmoor;25.11.18 13:00;25.11.18 13:30;;
Test 3;Wohldorfer Wald;25.11.18 13:00;25.11.18 13:30;;
Test 4;Heuckenlock;25.11.18 13:00;25.11.18 13:30;;
Test 5;Heuckenlock Ebbe;25.11.18 13:00;25.11.18 13:30;;
Test 6;Heuckenlock Flut;25.11.18 13:00;25.11.18 13:30;;
Test 7;Heuckenlock Flut;24.11.18 13:00;24.11.18 13:30;;
Begrüßung;Holzhafen;25.11.18 15:45;25.11.18 17:00;Ada Lovelace;EN
itte tragen Sie Ihre Programmpunkte hier ein;Raackmoor;25.11.18 15:45;25.11.18 17:00;Marie Curie;
Der Titel sollte max. ca. 45 Zeichen haben oder 50;Wohldorfer Wald;25.11.18 15:45;25.11.18 17:00;Donna Strickland;
Die möglichen Räume sind hier alle aufgeführt;Heuckenlock;25.11.18 15:45;25.11.18 17:00;Edith Clarke;
Testvortrag Ebbe;Heuckenlock Ebbe;25.11.18 15:45;25.11.18 17:00;Bjarne Stroustrup;
Testvortrag Flut;Heuckenlock Flut;25.11.18 15:45;25.11.18 17:00;Chris Lattner, Someone else;
Kaffeebuffet vor den Räumen (auf der Empore);Empore;25.11.18 15:45;25.11.18 17:00;;
Essen;Restaurant;25.11.18 15:45;25.11.18 17:00;;
Test 1 mit einem langen Titel;Holzhafen;25.11.18 17:00;25.11.18 17:30;;
Test 2 mit einem noch längeren Titel des Talks;Raackmoor;25.11.18 17:00;25.11.18 17:30;;
Test 3;Wohldorfer Wald;25.11.18 17:00;25.11.18 17:30;;
Test 4;Heuckenlock;25.11.18 17:00;25.11.18 17:30;;
Test 5;Heuckenlock Ebbe;25.11.18 17:00;25.11.18 17:30;;
Test 6;Heuckenlock Flut;25.11.18 17:00;25.11.18 17:30;;
Test 7;Heuckenlock Flut;24.11.18 17:00;24.11.18 17:30;;
1 Titel des Programmpunktes Raum Von (TT.MM.JJ HH:MM) Bis (TT.MM.JJ HH:MM) Vortragende Sprache (DE/EN)
2 Begrüßung Holzhafen 25.11.18 12:00 25.11.18 15:45 25.11.18 13:00 25.11.18 17:00 Ada Lovelace EN
3 Vortrag 1 itte tragen Sie Ihre Programmpunkte hier ein Raackmoor 25.11.18 12:00 25.11.18 15:45 25.11.18 13:00 25.11.18 17:00 Marie Curie
4 Noch ein Vortrag Der Titel sollte max. ca. 45 Zeichen haben oder 50 Wohldorfer Wald 25.11.18 12:00 25.11.18 15:45 25.11.18 13:00 25.11.18 17:00 Donna Strickland
5 Workshop Die möglichen Räume sind hier alle aufgeführt Heuckenlock 25.11.18 12:00 25.11.18 15:45 25.11.18 13:00 25.11.18 17:00 Edith Clarke
6 Testvortrag Ebbe Heuckenlock Ebbe 25.11.18 12:00 25.11.18 15:45 25.11.18 13:00 25.11.18 17:00 Bjarne Stroustrup
7 Testvortrag Flut Heuckenlock Flut 25.11.18 12:00 25.11.18 15:45 25.11.18 13:00 25.11.18 17:00 Chris Lattner Chris Lattner, Someone else
8 Test 1 Kaffeebuffet vor den Räumen (auf der Empore) Holzhafen Empore 25.11.18 13:00 25.11.18 15:45 25.11.18 13:30 25.11.18 17:00
9 Test 2 Essen Raackmoor Restaurant 25.11.18 13:00 25.11.18 15:45 25.11.18 13:30 25.11.18 17:00
10 Test 3 Test 1 mit einem langen Titel Wohldorfer Wald Holzhafen 25.11.18 13:00 25.11.18 17:00 25.11.18 13:30 25.11.18 17:30
11 Test 4 Test 2 mit einem noch längeren Titel des Talks Heuckenlock Raackmoor 25.11.18 13:00 25.11.18 17:00 25.11.18 13:30 25.11.18 17:30
12 Test 5 Test 3 Heuckenlock Ebbe Wohldorfer Wald 25.11.18 13:00 25.11.18 17:00 25.11.18 13:30 25.11.18 17:30
13 Test 6 Test 4 Heuckenlock Flut Heuckenlock 25.11.18 13:00 25.11.18 17:00 25.11.18 13:30 25.11.18 17:30
14 Test 7 Test 5 Heuckenlock Flut Heuckenlock Ebbe 24.11.18 13:00 25.11.18 17:00 24.11.18 13:30 25.11.18 17:30
15 Test 6 Heuckenlock Flut 25.11.18 17:00 25.11.18 17:30
16 Test 7 Heuckenlock Flut 24.11.18 17:00 24.11.18 17:30