考慮到你是編程新手,我建議如下。轉到google.drive.com並將south_camden_topo_v2.xlsx另存爲Google表格。現在,在文件選項卡上,將此文件保存爲csv文件,這是一種Python更容易處理的格式,即原始格式的xlsx格式。
我已經看過文件中的字段名稱。沒有人叫buildingHeight。但是,下面的代碼顯示瞭如何挖掘出可能需要的任何列。請注意,大多數記錄似乎缺乏大多數列的數據。
import csv
fieldWanted = 'RELH2'
with open('south_camden_topo_v2.xlsx - south_camden_topo_v2.csv') as csvFile:
reader = csv.reader(csvFile)
headings = next(reader)
fieldIndex = headings.index(fieldWanted)
print (headings)
count = 0
for row in reader:
print (row)
print (fieldWanted, ':', row[fieldIndex])
count += 1
if count > 5 :
break
請注意,該代碼僅輸出前幾條記錄,並從這些記錄中輸出RELH2的值。他們來了。
['FID', 'SCU_ID', 'SCU_CLASSI', 'POLY_SCU', 'THEMES', 'DHM_VOL', 'DHM_MEANH', 'DHM_STDDEV', 'DHM_MINH', 'DHM_MAXH', 'RELH2', 'RELHMAX']
['osgb1000005579280', '52101031610006', '1', 'TRUE', 'Buildings', '547.3700000000', '7.1087012987', '1.2253834286', '0.4000000000', '8.2600000000', '8.6000000000', '11.3000000000']
RELH2 : 8.6000000000
['osgb1000001802821881', '52101037490003', '9', '', 'Buildings', '', '', '', '', '', '', '']
RELH2 :
['osgb1000001802821884', '52101037490002', '9', '', 'Buildings', '', '', '', '', '', '', '']
RELH2 :
['osgb1000005575118', '52101032530003', '3', 'TRUE', 'Buildings', '', '', '', '', '', '', '']
RELH2 :
['osgb1000005574922', '52101052910008', '1', '', 'Buildings', '2449.5140000000', '10.7908105727', '3.3956447143', '0.0000000000', '17.5460000000', '11.6000000000', '19.4000000000']
RELH2 : 11.6000000000
['osgb1000005575392', '52101041010004', '1', '', 'Buildings', '', '', '', '', '', '', '']
RELH2 :
您試過了什麼?我幾乎不會打電話給你目前的嘗試 – smac89