Skip to content

Adding encoding specification parameter when opening yaml file - #86

Merged
timvink merged 2 commits into
timvink:masterfrom
kirill237:patch-2
Sep 14, 2026
Merged

timvink merged 2 commits into
timvink:masterfrom
kirill237:patch-2

Conversation

@kirill237

Copy link
Copy Markdown
Contributor

Adding the ability to specify in which encoding the file should be opened to generate a table from yaml

Adding the ability to specify in which encoding the file should be opened to generate a table from yaml
@timvink

timvink commented Aug 6, 2025

Copy link
Copy Markdown
Owner

Hee, thanks for the PR!

This could be an interesting addition. We should also add it to read_raw(). And document it (in docs/).

There's still a unit test to check though.

Comment on lines +137 to +139
if "encoding" in kwargs:
defaultEncoding = kwargs["encoding"]
del kwargs["encoding"]

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move this below the json_kwargs line. If pd.json_normalize() ever adds an encoding parameter, we would still be able to processs it.

Even better would be to just use: with open(args[0], "r", encoding=kwargs.get("encoding","UTF-8") as f:

Comment on lines +147 to +150
defaultEncoding = "UTF-8"
if "encoding" in kwargs:
defaultEncoding = kwargs["encoding"]
del kwargs["encoding"]

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same, just use encoding=kwargs.get("encoding","UTF-8") directly.

Simplify the encoding handling, add it to read_raw() as well,
document it and add a test with cp1251 encoded files.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JCJnK1rDt8rmDsXTFc7AHE
@timvink
timvink merged commit 05437aa into timvink:master Sep 14, 2026
13 checks passed
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.

2 participants