Skip to content

Commit 01a5df4

Browse files
authored
Merge pull request #360 from OpenDataServices/1285-sheetnames
input: Include sheet names in warnings about duplicate column headings
2 parents 7932c34 + bb86579 commit 01a5df4

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
66

77
## [Unreleased]
88

9+
- Include sheet name with duplicate heading warnings.
10+
911
## [0.13.0] - 2020-09-09
1012

1113
### Changed

flattentool/input.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ def do_unflatten(self):
333333
warn(
334334
(
335335
'Duplicate heading "{}" found, ignoring '
336-
"the data in columns {} and {}."
336+
'the data in columns {} and {} (sheet: "{}").'
337337
).format(
338338
actual_heading,
339339
", ".join(
@@ -343,28 +343,32 @@ def do_unflatten(self):
343343
]
344344
),
345345
_get_column_letter(ignoring[-1] + 1),
346+
sheet_name,
346347
),
347348
DataErrorWarning,
348349
)
349350
elif len(found[actual_heading]) == 3:
350351
warn(
351352
(
352353
'Duplicate heading "{}" found, ignoring '
353-
"the data in columns {} and {}."
354+
'the data in columns {} and {} (sheet: "{}").'
354355
).format(
355356
actual_heading,
356357
_get_column_letter(ignoring[0] + 1),
357358
_get_column_letter(ignoring[1] + 1),
359+
sheet_name,
358360
),
359361
DataErrorWarning,
360362
)
361363
else:
362364
warn(
363365
(
364366
'Duplicate heading "{}" found, ignoring '
365-
"the data in column {}."
367+
'the data in column {} (sheet: "{}").'
366368
).format(
367-
actual_heading, _get_column_letter(ignoring[0] + 1),
369+
actual_heading,
370+
_get_column_letter(ignoring[0] + 1),
371+
sheet_name,
368372
),
369373
DataErrorWarning,
370374
)

flattentool/tests/test_headings.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# Check we use the later values
1515
[1, 2],
1616
],
17-
['Duplicate heading "a" found, ignoring the data in column A.'],
17+
['Duplicate heading "a" found, ignoring the data in column A (sheet: "main").'],
1818
([OrderedDict([("a", 2)])], None, None),
1919
),
2020
(
@@ -24,9 +24,9 @@
2424
[1,],
2525
],
2626
[
27-
'Duplicate heading "b" found, ignoring the data in column B.',
28-
'Duplicate heading "c" found, ignoring the data in columns C and E.',
29-
'Duplicate heading "d" found, ignoring the data in columns G, H and I.',
27+
'Duplicate heading "b" found, ignoring the data in column B (sheet: "main").',
28+
'Duplicate heading "c" found, ignoring the data in columns C and E (sheet: "main").',
29+
'Duplicate heading "d" found, ignoring the data in columns G, H and I (sheet: "main").',
3030
],
3131
([OrderedDict([("a", 1)])], None, None),
3232
),

0 commit comments

Comments
 (0)