Skip to content

Commit e4fec47

Browse files
Style changes
1 parent 36771a9 commit e4fec47

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

mfr/extensions/tabular/libs/xlrd_tools.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,26 @@ def xlsx_xlrd(fp, max_iterations=5000):
4040
duplicate_fields = set([x for x in fields if fields.count(x) > 1])
4141
if len(duplicate_fields):
4242
counts = {}
43-
for name in duplicate_fields:
44-
counts[name] = 1
43+
for field in duplicate_fields:
44+
counts[field] = 1
45+
46+
for i, field in enumerate(fields):
47+
if field in duplicate_fields:
48+
increased_name = field + ' ({})'.format(counts[field])
4549

46-
for x in range(len(fields)):
47-
if fields[x] in duplicate_fields:
48-
name = fields[x]
49-
increased_name = name + ' ({})'.format(counts[name])
5050
# this triggers if you try to rename a header, and that new name
5151
# already exists in fields. it will then increment to look for the
5252
# next available name.
5353
iteration = 0
5454
while increased_name in fields:
5555
iteration += 1
5656
if iteration > max_iterations:
57-
increased_name = name + ' ({})'.format(uuid.uuid4())
57+
increased_name = field + ' ({})'.format(uuid.uuid4())
5858
else:
59-
counts[name] += 1
60-
increased_name = name + ' ({})'.format(counts[name])
59+
counts[field] += 1
60+
increased_name = field + ' ({})'.format(counts[field])
6161

62-
fields[x] = increased_name
62+
fields[i] = increased_name
6363
data = []
6464
for i in range(1, sheet.nrows):
6565
row = []

0 commit comments

Comments
 (0)