Skip to content

Commit

Permalink
read_catalog_from_csv: ensure that perfectly matching field names are…
Browse files Browse the repository at this point in the history
… correctly guessed
  • Loading branch information
claudiodsf committed Jun 14, 2024
1 parent 9155bf2 commit 692adb4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ Copyright (c) 2021-2024 Claudio Satriano <[email protected]>

## unreleased

- Improved readng of CSV catalog files: avoid duplicated column guessing, warn
if an invalid time format is found
- Improved reading of CSV catalog files:
- avoid duplicated column guessing
- ensure that prefectly matching column field names are correctly guessed
- warn if an invalid time format is found

## v0.6 - 2024-05-04

Expand Down
5 changes: 4 additions & 1 deletion requake/catalog/read_catalog_from_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@ def _field_match_score(field, field_list):
the field names in field_list
:rtype: int
"""
# return a very high score for a perfect match
if field.lower().strip() in field_list:
return 999
scores = [
len(guess)
for guess in field_list
if guess in field.lower()
if guess in field.lower().strip()
]
try:
return max(scores)
Expand Down

0 comments on commit 692adb4

Please sign in to comment.