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

Cannot set delimiter on CSV export #899

Open
mjmare opened this issue Mar 2, 2023 · 2 comments
Open

Cannot set delimiter on CSV export #899

mjmare opened this issue Mar 2, 2023 · 2 comments

Comments

@mjmare
Copy link

mjmare commented Mar 2, 2023

It seems that TableExport's parameter data_kwargs is not honoured when exporting a table.

I had to create this workaround in order to be able to set the delimiter:

class TableExportWithDelimiter(TableExport):

    def export(self):
        """
        Overide to provide a non standard delimiter. data_kwargs does not seem to work.
        """
        return self.dataset.export(self.format, delimiter=';')
@jieter
Copy link
Owner

jieter commented Mar 6, 2023

dataset_kwargs is passed as keyword arguments to the Dataset:

kwargs.update(dataset_kwargs or {})

tablib does not support setting the export format on the Dataset, which makes sense as that would couple it to a certain export format (CSV).

I suspected your example would only work to export to CSV, because the xlsx format does not support the delimiter kwarg, but apparently, unsupported kwargs are ignored.

We could fix this by adding another dict on ExportMixin which is passed to dataset.export(), but I'd say your custom TableExport class already looks like a good fix for non-standard use cases?

@mjmare
Copy link
Author

mjmare commented Mar 6, 2023

My example is CSV only indeed. My workaround works but overriding a class just to provide the delimiter kwart felt a bit heavy handed.

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

No branches or pull requests

2 participants