File tree Expand file tree Collapse file tree 1 file changed +10
-10
lines changed
mfr/extensions/tabular/libs Expand file tree Collapse file tree 1 file changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -40,26 +40,26 @@ def xlsx_xlrd(fp, max_iterations=5000):
40
40
duplicate_fields = set ([x for x in fields if fields .count (x ) > 1 ])
41
41
if len (duplicate_fields ):
42
42
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 ])
45
49
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 ])
50
50
# this triggers if you try to rename a header, and that new name
51
51
# already exists in fields. it will then increment to look for the
52
52
# next available name.
53
53
iteration = 0
54
54
while increased_name in fields :
55
55
iteration += 1
56
56
if iteration > max_iterations :
57
- increased_name = name + ' ({})' .format (uuid .uuid4 ())
57
+ increased_name = field + ' ({})' .format (uuid .uuid4 ())
58
58
else :
59
- counts [name ] += 1
60
- increased_name = name + ' ({})' .format (counts [name ])
59
+ counts [field ] += 1
60
+ increased_name = field + ' ({})' .format (counts [field ])
61
61
62
- fields [x ] = increased_name
62
+ fields [i ] = increased_name
63
63
data = []
64
64
for i in range (1 , sheet .nrows ):
65
65
row = []
You can’t perform that action at this time.
0 commit comments