Open PalGal2 opened 2 years ago
Is there a way to specify the "structure specific data" parameter ?
There is, but it's not very obvious, sorry.
In short:
to_xml()
) behaves differently depending on the class of objects it receives. See https://github.com/khaeru/sdmx/blob/4905936d688ae3136e12abe7745005c9539b532f/sdmx/writer/xml.py#L100-L104DataMessage
containing 1 or more StructureSpecificDataSet
, then it writes out structure-specific XML format. (If, on the other hand, the data message contains other kinds of data sets, it writes the generic/non-structure-specific format.)to_xml()
will happily write out structure-specific XML.Other thoughts:
struct_spec=True
when GenericDataSet is used. Added labels accordingly.Many thanks @khaeru, this is perfect.
I have just a minor question related to your answer : changing DataSet
to StructureSpecificDataset
works great, but I still have a repetition of dimensions at the level of observation, whereas I would like to have them at the series level (i.e. for a given series, the value changes only on the time period dimension). My demo is "cross-sectional data".
I wasn't able to find any documentation on that, but I am sure it is feasible with your library. Could you please give me some advice ?
Thank you so much.
I still have a repetition of dimensions at the level of observation, whereas I would like to have them at the series level (i.e. for a given series, the value changes only on the time period dimension). My demo is "cross-sectional data".
Without a specimen or example code, it's really not clear what precisely you're trying to do, and what result you're getting instead.
A wild guess: taking this example https://github.com/khaeru/sdmx-test-data/blob/f040d18abbcf6b40b1640e510fbea0f91aa22d60/ECB_EXR/ng-xs-ss.xml#L14-L20 —what you are saying is that some dimension, e.g. CURRENCY_DENOM, is being written as part of the individual <Obs …/>
XML elements, instead of as part of the containing <Series …></Series>
elements. Is that correct?
If so, note the writer code follows the structure of the data, e.g.
Observation.dimension
Key, and not in the DataSet.series
SeriesKey, then that's how they will be written out.I hope that helps to investigate the data structures you are writing out.
Thank you again for your precious help @khaeru. The example perfectly matches with what I would like to have in my final SDMX-ML file. I followed this tutorial which, however, does not present the <Series ...> elements.
How can I adapt this tutorial to add the series
argument in the sdmx.model.StructureSpecificDataset
but I do not know how. Is that correct ? Could you please give me some guidance please ?
Can you give some examples for the following arguments in sdmx.model.StructureSpecificDataSet
drawing on the tutorial (maybe to implement in the doc for other users?) :
group: sdmx.util.DictLike[sdmx.model.GroupKey, List[sdmx.model.Observation]]
Thank you again very much.
maybe to implement in the doc for other users?
As you note, this is a substantial expansion of the docs, i.e. a whole new tutorial. I think that would be a nice enhancement to have, but do not have time to do it at this moment. I also cannot write your code for you.
What I would suggest you do is:
Many thanks @khaeru for your time.
Let's keep the issue open as a TODO item for the eventual new tutorial.
Hi,
I would like to know if there is a method to write a Structure Specific Data SDMX-ML 2.1 with sdmx package.
It looks like that the to_xml function writes in generic by default. Is there a way to specify the "structure specific data" parameter ?
Many thanks