-
Notifications
You must be signed in to change notification settings - Fork 1
/
convert.py
47 lines (41 loc) · 1.06 KB
/
convert.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import csv
import sys
import json
import util
import pprint
import requests
import time
from bs4 import BeautifulSoup
from selenium import webdriver
from urllib.request import urlopen
from util import make_list
from util import print_table
import make_main
pp = pprint.PrettyPrinter()
INDEX_MIN = 2
# read csv
filename = sys.argv[1]
table_main = []
with open(filename) as csvfile:
spamreader = csv.reader(csvfile, delimiter='\t', quotechar='|')
cnt = -1
min, max = 1, 2147483647
for row in spamreader:
cnt += 1
if cnt == 0: continue
if cnt < min or cnt > max: continue
place = row[24]
track = row[6]
combined = ""
if place == "沙田":
combined += "田"
else:
combined += "谷"
if track[0] == "草":
combined += "草"
combined += track.split("\"")[1]
else:
combined += "泥"
row[6] = combined
row = row[:24] + ["", ""] + row[25:]
util.write_table_append([row], "output/Data Base (2018-2019) new.csv")