我是Python的初學者,我將它用於我的項目。如何從Python中的CSV文件行查找最小值?
我想提取從CSV文件的column4最小值,我不知道如何。
我可以打印整列[4]但我不知道如何從列打印最小值(只是一列)[4]。
CSV文件:https://www.emcsg.com/marketdata/priceinformation 我下載統一新加坡能源價格&需求預測9月9日
預先感謝您。
這是我當前的代碼:
import csv
import operator
with open('sep.csv') as csvfile:
readCSV = csv.reader(csvfile, delimiter=',')
header = next(readCSV)
data = []
for row in readCSV:
Date = row[0]
Time = row[1]
Demand = row[2]
RCL = row[3]
USEP = row [4]
EHEUR = row [5]
LCP = row[6]
Regulations = row[7]
Primary = row[8]
Secondary = row[9]
Contingency = row[10]
Last_Updated = row[11]
print header[4]
print row[4]
你有一些代碼;請在問題本身提供[mcve]。 –
您將行更改爲列,所以我編輯了我的答案。另外,請注意Python中的縮進。 – Alperen