Этот код разбивает градус, минуты и секунды координаты в другой столбец. я получаю сообщение об ошибке
import csv
import re
pattern = re.compile(r'[°\']')
# Here is process of reading of source file
with open('COORD.csv', newline='') as csv_file:
reader = csv.DictReader(csv_file, delimiter=';',)
new_list = []
for row in reader:
lat = pattern.split(row['lat'].replace('.', ',').strip('"'))
long = pattern.split(row['long'].replace('.', ',').strip('"'))
print(lat, long)
new_list.append((lat,long))
# Here is process of writing data in new file
with open('new.csv', 'w', newline='') as new_csv_file:
writer = csv.writer(new_csv_file, delimiter=';')
writer.writerow('latdeg latmin latsec longdeg longmin longsec'.split())
for coordinate in new_list:
writer.writerow(coordinate[0] + coordinate[1])
Это ошибка
Traceback (most recent call last):
File "C:/Users/Temmy/.PyCharmEdu2019.1/config/scratches/crawl.py", line 12, in <module>
lat = pattern.split(row['lat'].replace('.', ',').strip('"'))
KeyError: 'lat'