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':u
'lon', \
15 'SIRUTA':u
'siruta:code', \
16 'OLD_POSTAL':u
'old_postal_code', \
17 'RANG':u
'siruta:rank', \
18 'TIP':u
'siruta:type', \
19 'SIRUTA_SUP':u
'siruta:code_sup', \
20 'NAME_SUP':u
'siruta:name_sup', \
21 'COUNTY':u
'siruta:county', \
22 'COUNTY_ID':u
'siruta:county_id', \
23 'COUNTY_MN':u
'siruta:county_code', \
24 'POP2002':u
'population2002', \
26 'REGION_ID':u
'siruta:region_id', \
27 'ENVIRO_TYP':u
'siruta:enviro_type', \
28 'SORT_CODE':u
'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
)
49 d
[cell
] = unicode(d
[cell
], 'utf-8')