You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/api/reader.rst
+27-4Lines changed: 27 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -43,15 +43,38 @@ SDMX-JSON
43
43
:members:
44
44
:undoc-members:
45
45
46
+
47
+
.. currentmodule:: sdmx.reader.csv
48
+
46
49
SDMX-CSV
47
50
=========
48
51
49
-
.. currentmodule:: sdmx.reader.csv
52
+
:mod:`sdmx.reader.csv` supports SDMX-CSV 2.0.0, corresponding to SDMX 3.0.0.
53
+
See :ref:`sdmx-csv` for differences between versions of the SDMX-CSV file format.
50
54
51
-
.. autoclass:: sdmx.reader.csv.Reader
52
-
:members:
53
-
:undoc-members:
55
+
Implementation details:
56
+
57
+
- :meth:`.Reader.inspect_header` inspects the header line in the CSV input and constructs a set of :class:`~.csv.Handler` instances, one for each field appearing in the particular file.
58
+
Some of these handlers do actually process the contents of the field, but silently discard it; for example, when ``labels="name"``, the name fields are not processed.
59
+
- :meth:`.Reader.handle_row` is applied to every record in the CSV input.
60
+
Each Handler is applied to its respective field.
61
+
Every :meth:`.handle_row` call constructs a single :class:`~.v30.Observation`.
62
+
- :meth:`.Reader.read_message` assembles the resulting observations into one or more :class:`DataSets <.common.BaseDataSet>`.
63
+
SDMX-CSV 2.0.0 specifies a mix of codes such as "I" (:attr:`.ActionType.information`) and "D" (:attr:`.ActionType.delete`) in the "ACTION" field for each observation in the same file, whereas the SDMX IM specifies that :attr:`~.BaseDataSet.action` is an attribute of an entire DataSet.
64
+
:class:`~.csv.Reader` groups all observations into 1 or more DataSet instances, according to their respective "ACTION" field values.
65
+
66
+
Currently :mod:`.reader.csv` has the following limitations:
54
67
68
+
- :meth:`.Reader.read_message` generates SDMX 3.0.0 (:mod:`.model.v30`) artefacts such as :class:`.v30.DataSet`, since these correspond to the supported SDMX-CSV 2.0.0 format.
69
+
It is not currently supported to generate SDMX 2.1 artefacts such as :class:`.v21.DataSet`.
70
+
- Currently only a single :class`.v30.Dataflow` or :class:`.v30.DataStructureDefinition` can be supplied to :meth:`.Reader.read_message`.
71
+
The SDMX-CSV 2.0.0 format supports mixing data flows and data structures in the same message.
72
+
Such messages can be read with :mod:`sdmx`, but the resulting data sets will only correspond to the given data flow.
Copy file name to clipboardExpand all lines: doc/implementation.rst
+17-6Lines changed: 17 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -300,21 +300,32 @@ The SDMX-JSON *format* is versioned differently from the overall SDMX *standard*
300
300
SDMX-CSV
301
301
--------
302
302
303
-
Reference: https://github.com/sdmx-twg/sdmx-csv
303
+
Reference: https://github.com/sdmx-twg/sdmx-csv; see in particular the file `sdmx-csv-field-guide.md <https://github.com/sdmx-twg/sdmx-csv/blob/v2.0.0/data-message/docs/sdmx-csv-field-guide.md>`_.
304
304
305
305
Based on Comma-Separated Value (CSV).
306
306
The SDMX-CSV *format* is versioned differently from the overall SDMX *standard*:
307
307
308
308
- `SDMX-CSV 1.0 <https://github.com/sdmx-twg/sdmx-csv/tree/v1.0>`__ corresponds to SDMX 2.1.
309
309
It supports only data and metadata, not structures.
310
-
- SDMX-CSV 2.0 corresponds to SDMX 3.0.
310
+
SDMX-CSV 1.0 files are recognizable by the header ``DATAFLOW`` in the first column of the first row.
311
311
312
-
.. versionadded:: 2.9.0
312
+
.. versionadded:: 2.9.0
313
313
314
-
Support for SDMX-CSV 1.0.
314
+
Support for *writing* SDMX-CSV 1.0.
315
+
See :mod:`.writer.csv`.
315
316
316
-
:mod:`sdmx` does not currently support *writing* SDMX-CSV.
317
-
See :issue:`34`.
317
+
:mod:`sdmx` does not currently support *reading* SDMX-CSV 1.0.
318
+
319
+
- `SDMX-CSV 2.0.0 <https://github.com/sdmx-twg/sdmx-csv/tree/v2.0.0>`_ corresponds to SDMX 3.0.0.
320
+
The format differs from and is not backwards compatible with SDMX-CSV 1.0.
321
+
SDMX-CSV 2.0.0 files are recognizable by the header ``STRUCTURE`` in the first column of the first row.
322
+
323
+
.. versionadded:: 2.19.0
324
+
325
+
Initial support for *reading* SDMX-CSV 2.0.0.
326
+
See :mod:`.reader.csv`.
327
+
328
+
:mod:`sdmx` does not currently support *writing* SDMX-CSV 2.0.0.
See the implementation notes for information about the differences between the SDMX-CSV 1.0 and 2.0.0 formats and their support in :mod:`sdmx`.
9
11
- Bug fix for writing :class:`.VersionableArtefact` to SDMX-ML 2.1: :class:`KeyError` was raised if :attr:`.VersionableArtefact.version` was an instance of :class:`.Version` (:pull:`198`).
10
12
- Bug fix for reading data from structure-specific SDMX-ML: :class:`.XMLParseError` / :class:`NotImplementedError` was raised if reading 2 messages in sequence with different XML namespaces defined (:pull:`200`, thanks :gh-user:`mephinet` for :issue:`199`).
0 commit comments