Fix for duplicate rows in csv subscription list

This commit is contained in:
Amit Chakradeo 2011-02-17 17:04:43 -08:00
parent 2cde902af3
commit d7c771bfbc
2 changed files with 6 additions and 1 deletions

View File

@ -11,9 +11,12 @@ def csv2config(input, config=None):
config = ConfigParser() config = ConfigParser()
reader = csv.DictReader(input) reader = csv.DictReader(input)
d = {}
for row in reader: for row in reader:
section = row[reader.fieldnames[0]] section = row[reader.fieldnames[0]]
config.add_section(section) if not d.get(section):
config.add_section(section)
d[section] = 1
for name, value in row.items(): for name, value in row.items():
if value and name != reader.fieldnames[0]: if value and name != reader.fieldnames[0]:
config.set(section, name, value) config.set(section, name, value)

View File

@ -1,3 +1,5 @@
url,name,filters url,name,filters
feed1,one feed1,one
feed1,one
feed2,two,bar
feed2,two,bar feed2,two,bar

1 url,name,filters
2 feed1,one
3 feed1,one
4 feed2,two,bar
5 feed2,two,bar