Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flattening a list of lists #398

Closed
duncandewhurst opened this issue Aug 9, 2022 · 6 comments
Closed

Flattening a list of lists #398

duncandewhurst opened this issue Aug 9, 2022 · 6 comments
Labels

Comments

@duncandewhurst
Copy link
Contributor

I'm trying to flatten this file using the following command: flatten-tool flatten -f xlsx example.json. However, the resulting xlsx file is empty.

Flattening the nodes list with flatten-tool flatten -f xlsx --root-list-path nodes example.json works OK. However, flattening the links list with flatten-tool flatten -f xlsx --root-list-path links example.json returns an error: 'list' object has no attribute 'items'.

I think this is because links.location.geometry.coordinates is a list of lists (the list in the actual file is longer):

{
  "links": [
    {
       "location": {
          "coordinates": [
              [
                26.081,
                -24.406
              ],
              [
                26.081,
                -24.406
              ]
           ]
        }
     }
  ]
}
@Bjwebb
Copy link
Member

Bjwebb commented Aug 23, 2022

Yes, it looks like we lack support for flattening of lists of lists. Here's a TODO in the code https://github.com/OpenDataServices/flatten-tool/blob/main/flattentool/json_input.py#L422 !

It should be fairly easy to implement this, to produce a cell with the contents 26.081,-24.406;26.081,-24.406. @duncandewhurst is that what you expect?

@duncandewhurst
Copy link
Contributor Author

Thanks, @Bjwebb. I was expecting something like [26.081;-24.405]; [26.09; -24.416] but your suggestion looks easier to work with.

We've yet to decide whether we're going to use Flatten Tool for Open Fibre (see Open-Telecoms-Data/open-fibre-data-standard#14) so no need to implement this yet.

@Bjwebb
Copy link
Member

Bjwebb commented Aug 24, 2022

For info, my suggestion is based on what we already support for unflattening (which I think requires a schema).

@duncandewhurst
Copy link
Contributor Author

@Bjwebb we've decided to use Flatten Tool for the Open Fibre alpha, would you have time to implement this before you go on leave?

@Bjwebb
Copy link
Member

Bjwebb commented Sep 26, 2022

I've made a PR for this #401

@duncandewhurst
Copy link
Contributor Author

Closing as the PR is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants