sgf-parser 0.0.1b2__tar.gz → 0.0.1b4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sgf-parser
3
- Version: 0.0.1b2
3
+ Version: 0.0.1b4
4
4
  Summary: Parser for the Swedish Geotechnical Society / Svenska Geotekniska Föreningen (SGF) data format
5
5
  Home-page: https://github.com/norwegian-geotechnical-institute/sgf-parser
6
6
  License: MIT
@@ -15,7 +15,7 @@ exclude = '''
15
15
 
16
16
  [tool.poetry]
17
17
  name = "sgf-parser"
18
- version = "0.0.1b2"
18
+ version = "0.0.1b4"
19
19
  description = "Parser for the Swedish Geotechnical Society / Svenska Geotekniska Föreningen (SGF) data format"
20
20
  license = "MIT"
21
21
  authors = ["Jostein Leira <jostein@leira.net>"]
@@ -52,15 +52,30 @@ class MethodData(BaseModel, abc.ABC):
52
52
  Sometimes we get more than one code on a data row, then we need to prioritize what code to keep.
53
53
  """
54
54
  if isinstance(data, dict):
55
- # Detect string variants of the comment code and convert them to integers
56
55
  if "K" in data and data["K"] is not None:
57
- _code, _rest = cls._extract_comment_code(data)
58
- data["K"] = _code
59
- if _rest:
60
- if data["T"]:
61
- data["T"] = f"{_rest}, {data['T']}"
56
+
57
+ # We want to interpret K as a stop code (with integer value)
58
+ # sometimes K is a string with e.g. "SAND", in that case we move it to T
59
+ K_is_digit = any(char.isdigit() for char in data["K"])
60
+
61
+ if not K_is_digit:
62
+ # move it to T (remarks column)
63
+ if "T" not in data:
64
+ data["T"] = data["K"]
62
65
  else:
63
- data["T"] = _rest
66
+ data["T"] = f"{data['K']}, {data['T']}"
67
+
68
+ del data["K"]
69
+
70
+ else:
71
+ # we identify the most important stop code, and move the rest to T
72
+ _code, _rest = cls._extract_comment_code(data)
73
+ data["K"] = _code
74
+ if _rest:
75
+ if "T" not in data:
76
+ data["T"] = _rest
77
+ else:
78
+ data["T"] = f"{_rest}, {data['T']}"
64
79
 
65
80
  return data
66
81
 
File without changes
File without changes