gpt4 book ai didi

python从sqlite数据库导出csv文件,大写 "L"的值被截断

转载 作者:太空宇宙 更新时间:2023-11-03 15:49:10 26 4
gpt4 key购买 nike

 import sqlite3
import pandas as pd


f = open('output.csv', 'w')

connection = sqlite3.connect('storage.sqlite')
cursor = connection.cursor()
cursor.execute('select * from product')

while True:
df = pd.DataFrame(cursor.fetchmany(1000))
if len(df) == 0:
break

else:
df.to_csv(f, header=False)

f.close()
cursor.close()
connection.close()

enter image description here

这里的数据是“Long Lad as”,因此在导入时我在 csv 的不同单元格中得到了“ong ad as”。

小写的“l”不受影响,但大写的 L 在导出时被删除。

请帮助修复此错误

最佳答案

查看您的图像 - 您已将 L 设置为 Other 分隔符 - 因此您在导入文件时删除 L

CSV 是普通文本文件,因此您可以在普通编辑器中打开并查看文本中是否有此 L

关于python从sqlite数据库导出csv文件,大写 "L"的值被截断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41457709/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com