為了要從大數據裡面的csv檔撈出資料,
605是郵遞區號,從資料當中找出郵遞區號為'605'的row
因為row是一串數字,所以要從row[1] 是因為資料裡的[1]是我要的那一串數字,數字的第8~10就是郵遞區號
import csv
def csv_operater():
path1 = "csv的檔案位置" path2 = "csv的檔案位置"
with open(path1, "r") as csvFile:
with open(path2, "w", newline='') as csvWrite:
i = 0 reader = csv.reader(csvFile)
writer = csv.writer(csvWrite)
for row in reader:
if '605' in row[1][8:11]:
writer.writerow(row)
csvWrite.close()
csvFile.close()
def test():
with open("csv檔案位置", "r") as csvFile:
reader = csv.reader(csvFile)
sum = 0 sum2 = 0 proxy_list = ['60591', '60593', '60594', '60595', '60596', '60598']
proxy_count = [0, 0, 0, 0, 0, 0]
town = []
town_count = []
for row in reader:
sum2 += 1 if row[1][8:13] not in town:
#writer.writerow(row) town.append(row[1][8:13])
print(town)
town_count.append(0)
if row[1][8:13] in town:
town_count[town.index(row[1][8:13])] += 1
if '60593' in town:
print("find")
for i in range(len(town)):
print("{1}".format(town[i], town_count[i]))
def print_ari():
with open("csv檔案位置", "r") as csvFile:
reader = csv.reader(csvFile)
i = 0 for row in reader:
if i < 10:
print(row)
i += 1
#csv_operater()test()
#print_ari()