Python Pandas导出到CSV无法正确处理逃脱

发布于 2025-02-05 11:44:09 字数 466 浏览 1 评论 0原文

我有以下问题:我读了一个具有以下顺序的CSV \“ \\\” 哪个熊猫的读数正确(因为如果我打印数据框,它会输出“ \/code>。 /代码>在软件中不起作用的导出CSV使用。

我用来读取CSV的设置:

import = pd.read_csv('input.csv', sep="|", dtype=str, quotechar='"', escapechar="\\")

导出设置:

import.to_csv('export.csv', sep="|", index=False, encoding='utf-8', escapechar="\\", quoting=csv.QUOTE_NONNUMERIC, doublequote=False)

这为我提供了我所拥有的其他所有结果

I have the following problem: i read a csv with the following sequence
\"\\\"
which pandas reads correctly (because if i print the dataframe it outputs "\". But if i now export the dataframe again to csv it will give me the character sequence \"\\" which is not working in the software the exported csv gets used in.

The settings I use to read the csv:

import = pd.read_csv('input.csv', sep="|", dtype=str, quotechar='"', escapechar="\\")

Export settings:

import.to_csv('export.csv', sep="|", index=False, encoding='utf-8', escapechar="\\", quoting=csv.QUOTE_NONNUMERIC, doublequote=False)

This gives me for everything else I have correct results.

I appreciate any help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文