Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Output formatter corrupts original data #578

@MaxKh

Description

@MaxKh

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions