ssb-konjunk 0.1.22__tar.gz → 1.0.1__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,10 +1,10 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: ssb-konjunk
3
- Version: 0.1.22
4
- Summary: SSB Konjunk
3
+ Version: 1.0.1
4
+ Summary: SSB Konjunk 422
5
5
  License: MIT
6
- Author: Edvard Garmannslund
7
- Author-email: ged@ssb.no
6
+ Author: Johanne Saxegaard
7
+ Author-email: jox@ssb.no
8
8
  Requires-Python: >=3.10,<4.0
9
9
  Classifier: Development Status :: 1 - Planning
10
10
  Classifier: License :: OSI Approved :: MIT License
@@ -44,7 +44,6 @@ Description-Content-Type: text/markdown
44
44
  [pypi status]: https://pypi.org/project/ssb-konjunk/
45
45
  [documentation]: https://statisticsnorway.github.io/ssb-konjunk
46
46
  [tests]: https://github.com/statisticsnorway/ssb-konjunk/actions?workflow=Tests
47
-
48
47
  [sonarcov]: https://sonarcloud.io/summary/overall?id=statisticsnorway_ssb-konjunk
49
48
  [sonarquality]: https://sonarcloud.io/summary/overall?id=statisticsnorway_ssb-konjunk
50
49
  [pre-commit]: https://github.com/pre-commit/pre-commit
@@ -18,7 +18,6 @@
18
18
  [pypi status]: https://pypi.org/project/ssb-konjunk/
19
19
  [documentation]: https://statisticsnorway.github.io/ssb-konjunk
20
20
  [tests]: https://github.com/statisticsnorway/ssb-konjunk/actions?workflow=Tests
21
-
22
21
  [sonarcov]: https://sonarcloud.io/summary/overall?id=statisticsnorway_ssb-konjunk
23
22
  [sonarquality]: https://sonarcloud.io/summary/overall?id=statisticsnorway_ssb-konjunk
24
23
  [pre-commit]: https://github.com/pre-commit/pre-commit
@@ -1,8 +1,8 @@
1
1
  [tool.poetry]
2
2
  name = "ssb-konjunk"
3
- version = "0.1.22"
4
- description = "SSB Konjunk"
5
- authors = ["Edvard Garmannslund <ged@ssb.no>"]
3
+ version = "1.0.1"
4
+ description = "SSB Konjunk 422"
5
+ authors = ["Johanne Saxegaard <jox@ssb.no>"]
6
6
  license = "MIT"
7
7
  readme = "README.md"
8
8
  homepage = "https://github.com/statisticsnorway/ssb-konjunk"
@@ -60,6 +60,9 @@ relative_files = true
60
60
  show_missing = true
61
61
  fail_under = 50
62
62
 
63
+ [tool.deptry.per_rule_ignores]
64
+ DEP001 = ["nox", "nox_poetry"] # packages available by default
65
+
63
66
  [tool.mypy]
64
67
  strict = true
65
68
  warn_unreachable = true
@@ -96,7 +99,7 @@ select = [
96
99
  "RUF", # the ruff developer's own rules
97
100
  ]
98
101
  ignore = [
99
- "ANN202", # Don't requiere return type annotation for private functions.
102
+ "ANN202", # Don't require return type annotation for private functions.
100
103
  "ANN401", # Allow type annotation with type Any.
101
104
  "D100", # Supress undocumented-public-module. Only doc of public api required.
102
105
  "FBT001", # Allow boolean positional arguments in a function.
@@ -5,6 +5,7 @@ Follows the the standardization for versioning and names.
5
5
 
6
6
  import glob
7
7
  import re
8
+ import warnings
8
9
 
9
10
  import dapla
10
11
  import pandas as pd
@@ -350,6 +351,7 @@ def read_ssb_file(
350
351
  datatilstand: str = "",
351
352
  undermappe: str | None = None,
352
353
  filetype: str = "parquet",
354
+ columns: list[str] | None = None,
353
355
  version_number: int | None = None,
354
356
  fs: dapla.gcs.GCSFileSystem | None = None,
355
357
  seperator: str = ";",
@@ -371,6 +373,7 @@ def read_ssb_file(
371
373
  undermappe: Optional folder under 'datatilstand'.
372
374
  version_number: possibility to get another version, than the newest (i.e. highest version number). Default: np.nan.
373
375
  filetype: the filetype to save as. Default: 'parquet'.
376
+ columns: Columns to read from the file. If None (default), all columns are read.
374
377
  fs: the filesystem, pass with gsc Filesystem if Dapla. Default: None.
375
378
  seperator: the seperator to use it filetype is csv. Default: ';'.
376
379
  encoding: Encoding for file, base is latin1.
@@ -411,15 +414,27 @@ def read_ssb_file(
411
414
  if fs:
412
415
  # Samme som tidligere kan brukes til å lese alle filformater.
413
416
  with fs.open(file_path, "r") as f:
414
- df = pd.read_csv(f, sep=seperator, encoding=encoding)
417
+ df = pd.read_csv(f, sep=seperator, encoding=encoding, usecols=columns)
415
418
  f.close()
416
419
  else:
417
- df = pd.read_csv(file_path, sep=seperator, encoding=encoding)
420
+ df = pd.read_csv(
421
+ file_path, sep=seperator, encoding=encoding, usecols=columns
422
+ )
418
423
  elif filetype == "parquet":
419
- df = pd.read_parquet(file_path, filesystem=fs)
424
+ df = pd.read_parquet(file_path, columns=columns, filesystem=fs)
420
425
  elif filetype == "jsonl":
421
- df = pd.read_json(file_path, lines=True)
426
+ if columns is not None:
427
+ warnings.warn(
428
+ f"Columns argumentet blir ignorert for {filetype} filer, hele filen vil bli lastet inn.",
429
+ stacklevel=2,
430
+ )
431
+ df = pd.read_json(file_path, lines=False)
422
432
  elif filetype == "json":
433
+ if columns is not None:
434
+ warnings.warn(
435
+ f"Columns argumentet blir ignorert for {filetype} filer, hele filen vil bli lastet inn.",
436
+ stacklevel=2,
437
+ )
423
438
  df = pd.read_json(file_path, lines=False)
424
439
  # Returns pandas df.
425
440
  return df
File without changes