我正在尝试过滤掉https://www.keepright.at/interfacing.php#DUMP
中的某些错误我设法用我在下面写的代码做了一些出口,它适用于美国或加拿大,但是当我尝试导出厄瓜多尔时,我没有得到任何结果。
我认为问题在于数据的评论部分中有字符('",。/),我不知道如何逃避它们
import csv
import time
print("Welcome to the keepright error filter")
workDir = input("insert the path where keepright_errors.txt can be found:")
print(workDir)
ErrOpt = input("Enter values for the category you want separated by commas ex: 210,300 : ")
print(ErrOpt)
ErrOpt = ErrOpt.split((","))
print(ErrOpt)
second_col = []
print(
"""
USA 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,49,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67
CANADA 20,21,22,23
"""
)
AreaOpt = input ("Enter the values for your area of interest separated by coma : ")
AreaOpt = AreaOpt.split((","))
timestr = time.strftime("%Y%m%d-%H%M%S") #timestamp for file
with open(str(workDir) + '/keepright_errors.txt', encoding='latin-1', newline='') as csvfile, open(str(workDir) + '/keepright-A' + '-' + timestr + '.csv', 'w', encoding='latin-1') as o:
citire = csv.reader(csvfile, delimiter='\t', quoting=csv.QUOTE_NONE)
next(citire, None)
scriere = csv.writer(o, delimiter='\t', quoting=csv.QUOTE_NONE)
for row in citire:
row[11] = int(row[11]) / (10 ** 7) #transforming lat/long from integer to float
row[12] = int(row[12]) / (10 ** 7)
if row[2] in (ErrOpt):
if row[0] in (AreaOpt):
scriere.writerow(row)