Skip to content

Commit

Permalink
changed regex to check the references
Browse files Browse the repository at this point in the history
  • Loading branch information
BernhardKoschicek committed Oct 18, 2024
1 parent 423f85d commit 42ff1c0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion openatlas/models/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,5 @@ def insert_gis(entity: Entity, row: dict[str, Any], project: Project) -> None:


def clean_reference_pages(value: str) -> list[str]:
return re.findall(r'\d+;.*?(?=\d+;|$)', value)
matches = re.findall(r'([a-zA-Z\d]*;[^;]*?(?=[a-zA-Z\d]*;|$))', value)
return [match.strip() for match in matches]
2 changes: 1 addition & 1 deletion sphinx/source/admin/import.rst
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ References
It is possible to link existing :doc:`/entity/reference` to imported entities.

* :doc:`/entity/reference` ID and pages are separated with a semicolon (**;**), e.g. 1234;56-78
* To link :doc:`/entity/reference` with multiple page numbers, wrap the whole cell in quotation marks, e.g. "1234;IV, 56-78"
* To link :doc:`/entity/reference` with multiple page numbers, wrap the whole cell in quotation marks, e.g. "1234;IV, 56-78 542;34-23 66;"
* To link :doc:`/entity/reference` without page number, just add the ID semicolon (**;**) without additional information
* You can enter multiple :doc:`/entity/reference` separated with a space, e.g. 1234;56-78 5678;
* The ID of a :doc:`/entity/reference` can be looked up at the detail view of the entity
Expand Down
6 changes: 3 additions & 3 deletions tests/invalid_2.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
id,name,alias,description,begin_from,begin_to,begin_comment,end_from,end_to,end_comment,wkt,type_ids,value_types,references,reference_system_wikidata,reference_system_geon,administrative_unit,historical_place,not_existing_column
place_1,Vienna,Wien,Capital of Austria,not_a_date,NaT,It was a rainy day.,,2049-12-31,"We'll see about that.","MULTILINESTRING ((10 10, 20 20, 10 40),(40 40, 30 30, 40 20, 30 10))",666,666;12B34,666;213;41 12b 666b;IV,123;away,juhhu;4545,777,888,
place_1,,,,,,,,,,"MULTILINESTRING ((BLA 10, 20 20, 10 40),(40 40, 30 30, 40 20, 30 10))",,,,,,
place_1,Vienna,,,,,,,,,,,,,,
place_1,Vienna,Wien,Capital of Austria,not_a_date,NaT,It was a rainy day.,,2049-12-31,We'll see about that.,"MULTILINESTRING ((10 10, 20 20, 10 40),(40 40, 30 30, 40 20, 30 10))",666,666;12B34,“666b;213;41 12b 666;IV,123;away,juhhu;4545,777,888,
place_1,,,,,,,,,,"MULTILINESTRING ((BLA 10, 20 20, 10 40),(40 40, 30 30, 40 20, 30 10))",,,,,,,,
place_1,Vienna,,,,,,,,,,,,,,,,,

0 comments on commit 42ff1c0

Please sign in to comment.