Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Here, we're creating a .csv file that organises the data files in respect of the date participation occurred
- newDataFile = open('by_date_results.csv', 'w')
- allData = sorted(listdir('results'))
- participationDate = {}
- for file in allData:
- datum = open('results/' + file, 'r')
- allLines = datum.readlines()
- day = allLines[1]
- day = day[6:14]
- day = day[:2] + '-' + day[2:4] + '-' + day[4:] # Formatting such that day/month/year are easily distinguished
- participationDate[day] = 0
- totalParticipants = 0
- for day in participationDate: # Collating participant's condition on each day
- conditionByDay = [0, 0, 0]
- if 'luck' in allLines[0]:
- conditionByDay[0] += 1
- totalParticipants += 1 # Collating total number of participant's per day irrespective of condition
- elif 'mixed' in allLines[0]:
- conditionByDay[1] += 1
- totalParticipants += 1
- elif 'skill' in allLines[0]:
- conditionByDay[2] += 1
- totalParticipants += 1
- if day in participationDate:
- if 'luck' in allLines[0]:
- conditionByDay[0] += 1
- totalParticipants += 1 # Collating total number of participant's per day irrespective of condition
- elif 'mixed' in allLines[0]:
- conditionByDay[1] += 1
- totalParticipants += 1
- elif 'skill' in allLines[0]:
- conditionByDay[2] += 1
- totalParticipants += 1
- participationDate[day] = conditionByDay
- for day in participationDate:
- newDataFile.write(f'{day}, {conditionByDay[0]}, {conditionByDay[1]}, {conditionByDay[2]}, {totalParticipants}\n')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement