1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- import csv
- import codecs
- import pandas as pd
- import re
- import os
- import io
- import tokenize
- merged_data = open('mergeASPO.csv', 'w')
- csvwriter = csv.writer(merged_data)
- '''params = ['codice', 'sigla']'''
- params = ['PLACE NAME', 'ID ASPO', 'ID RESTORE']
- csvwriter.writerow(params)
- '''
- def get_idR(place):
- link_file = open('/Users/alessiaspadi/Documents/RESTORE/temp_ovi/prove/altro/Luoghi.csv')
- reader = csv.DictReader(link_file)
- for row in reader:
- name_place = row['name_place'].lower()
- pp = place.lower()
- if name_place == pp:
- return row['id']
- '''
- def get_aspoId(place):
- link_file = open('/Users/alessiaspadi/Documents/RESTORE/temp_ASPO/Luoghi/Associa/Luoghi_ASPO.csv')
- reader = csv.DictReader(link_file)
- for row in reader:
- id_place = row['ID ASPO']
- id_restore = row['ID RESTORE']
- if place == id_place:
- return id_restore
- merge_file = open('/Users/alessiaspadi/Documents/RESTORE/temp_ASPO/Luoghi/Associa/data_eac_geo.csv')
- reader = csv.DictReader(merge_file)
- for row in reader:
- line = []
- id_luogo = row['ID ASPO']
- nome_luogo = row['PLACE NAME']
- id_aspo = get_aspoId(id_luogo)
- line.append(nome_luogo)
- line.append(id_luogo)
- if id_aspo is not None:
- line.append(id_aspo)
- else:
- line.append("")
- csvwriter.writerow(line)
- merged_data.close()
|