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

WIP: preliminary support for XML, 2020 #464

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

DeepSpace2
Copy link

@DeepSpace2 DeepSpace2 commented Apr 8, 2020

Hi all.

Before I start, I'm aware of #224 but it is 4 years old and tablib has changed quite extensively since then (dropped Python 2 support, format extensions are now classes, etc) so I thought I'd have a go at it.

It's a WIP and only supports export of dataset, but it supports tags.

The dataset

data = Dataset(headers=['first_name', 'last_name', 'gpa'])
data.append(('John', 'Adams', 90))
data.append(('George', 'Washington', 67), tags=['tag 1', 'tag 2'])

is exported as

<dataset>
    <row>
        <first_name>John</first_name>
        <last_name>Adams</last_name>
        <gpa>90</gpa>
    </row>
    <row tags="tag 1,tag 2">
        <first_name>George</first_name>
        <last_name>Washington</last_name>
        <gpa>67</gpa>
    </row>
</dataset>

I do have a question: Is there a proper way to access a row's tags while iterating over the dataset? The only way I found is to use enumerate and then use the row's index to index into _data which of course if unfavorable.

for row_index, row in enumerate(dataset.dict):
    tags = dataset._data[row_index].tags

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

Successfully merging this pull request may close these issues.

None yet

1 participant