# -*- coding: utf-8 -*-
import csv
import random
nomfichier="grosfichier2.csv"
tableau = []
with open(nomfichier, newline='') as csvfile:
objetcsv = csv.reader(csvfile, delimiter=',')
for ligne in objetcsv:
tableau.append(ligne)
def max_pt_date(points,date):
points = 0
for ligne in tableau:
if (ligne[1] == date):
if (int(ligne[3]) > points):
points = int(ligne[3])
return points
def listeDates():
dates = []
colonne = 1
for ligne in tableau:
if not (ligne[colonne] in dates) and ligne[colonne] != 'Date' :
dates.append(ligne[colonne])
return dates
def max_pt_dates_tot(date):
tout = []
lesDates = listeDates()
for date in lesDates:
tout.append([date,max_pt_date,(date)])
return tout
def toutlesmax():
tout = []
for date in listeDates():
tout.append(max_pt_dates_tot(date))
return tout
for ligne in toutlesmax():
print(ligne)
The objective of this code is to find, in a csv file, every maximum point production per date, which is in this form : 2022-04-20_11:58:02. This file includes dates from multiples months and years.
Code is returning values in a way i've never seen, can someone help me ?
CodePudding user response:
This usually happens when you forget to add the () at the end of a function. I think I see your problem in the max_pt_dates_tot function. There is a comma between max_pt_date and (date).