jazzband / tablib

Python Module for Tabular Datasets in XLS, CSV, JSON, YAML, &c.
https://tablib.readthedocs.io/
MIT License
4.6k stars 592 forks source link

Output formatter corrupts original data #578

Closed MaxKh closed 6 months ago

MaxKh commented 7 months ago

version: 3.5.0 python 3.11

I'm trying to export the same dataset several times in different file formats. I've found that specifying a formatter for a column data alters the underlying data. The issue occurs if exporting the same format too.

import tablib

dataset = tablib.Dataset()
dataset.headers = ["text"]
dataset.append(["aAbBcC"])
dataset.add_formatter("text", lambda s: s[2:])

print(dataset.export("csv"))
print(dataset.export("csv"))

Output:

text
bBcC

text
cC
claudep commented 7 months ago

Thanks for the report! Do you want to test the above pull request?

MaxKh commented 7 months ago

I'll wait for a new release. Thanks

hugovk commented 7 months ago

If you can test it, it would help us know if it really fixes it, means we can release sooner, and potentially avoid re-fixing later.