Python Forum
Python School Project
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python School Project
#3
use the csv modul to read the file

and max to find the highest value (replace /path/to/file.csv with your path)

import csv

# Columns: Fra;Til;KWH 60 Forbruk

scores_list = []

def findValue():
    with open("/path/to/file.csv") as csvfile:
        reader = csv.DictReader(csvfile, delimiter = ";")
        # replace comma with point and find highest float in KWH 60 Forbruk
        maxnum = max(reader, key=lambda row: float(row["KWH 60 Forbruk"].replace(",", ".")))
        print(maxnum)

findValue()
Output:
{'Fra': '20.07.2019 21:00', 'Til': '20.07.2019 22:00', 'KWH 60 Forbruk': '6,554'}
Reply


Messages In This Thread
Python School Project - by andreas30298 - Nov-12-2020, 05:31 AM
RE: Python School Project - by DPaul - Nov-12-2020, 07:39 AM
RE: Python School Project - by Axel_Erfurt - Nov-12-2020, 09:58 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  my python project for school vavervirus 2 752 Oct-12-2023, 03:28 AM
Last Post: buran
Shocked School project -- need help with it it says syntax error XPGKNIGHT 6 3,446 Aug-11-2022, 08:43 PM
Last Post: deanhystad
  School project janivar91 3 2,822 Jan-23-2021, 06:31 AM
Last Post: KonohaHokage
  I need help for a school project IndyNeerhoff 1 2,151 Sep-28-2019, 08:28 PM
Last Post: Gribouillis
  [Tkinter] Tkinter project school Kersow 2 2,540 Apr-08-2019, 08:45 PM
Last Post: Larz60+
  card dealer school project kalle1234 5 12,937 Jan-05-2019, 09:21 PM
Last Post: ichabod801
  School python program task help TommyLee 3 4,131 Apr-17-2018, 04:44 AM
Last Post: tannishpage
  Small game (school project) Ganesh 7 5,755 Nov-08-2017, 09:04 PM
Last Post: Ganesh

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020