5 class SirutaDictReader(csv
.DictReader
):
7 A CSV dict reader which maps the CSV field names to proper OSM tag names
10 def _mapCSVNamesToOSMNames(self
, csvnames
):
12 namemap
= { 'X':'lon', \
15 'SIRUTA':'siruta:code', \
16 'OLD_POSTAL':'old_postal_code', \
17 'RANG':'siruta:rank', \
18 'TIP':'siruta:type', \
19 'SIRUTA_SUP':'siruta:code_sup', \
20 'NAME_SUP':'siruta:name_sup', \
21 'COUNTY':'siruta:county', \
22 'COUNTY_ID':'siruta:county_id', \
23 'COUNTY_MN':'siruta:county_code', \
24 'POP2002':'population2002', \
26 'REGION_ID':'siruta:region_id', \
27 'ENVIRO_TYP':'siruta:enviro_type', \
28 'SORT_CODE':'siruta:sortcode' }
32 # although this will fail if unknown rows appear, that
33 # is the intended behaviour since we don't want to silently
34 # add or ignore fields unintentionaly
35 osmnames
.append(namemap
[name
])
40 if self
.fieldnames
is None:
41 row
= self
.reader
.next()
42 row
= self
._mapCSVNamesToOSMNames
(row
)
45 d
= csv
.DictReader
.next(self
)