[英]Quotes created while importing a descripitive csv using pandas
在导入带有描述和 #s 的 CSV 时。 Pandas 自动创建不需要的逗号。 如何导入没有引号的 CSV?
输入文件如下,
# In this file, you have to specify which information you want to
# extract from the data base.
#
# 6 parts of desired data have to be selected:
#
# 1. cloud or aerosol type
# 2. height profile
# 3. wavelengths
# 4. relative humidity
# 5. max. radius for mass calculations
# 6. optical parameters
#
# All lines which don't start with a "#" have to be filled in.
代码:
import pandas as pd
file_path ='/media/input/op.inp'
df = pd.read_csv(file_path, sep='delimiter'
df.to_csv('out.csv',index=False)
Output csv
# In this file, you have to specify which information you want to"
# extract from the data base.
#
# 6 parts of desired data have to be selected:
#
# 1. cloud or aerosol type
# 2. height profile
# 3. wavelengths
# 4. relative humidity
# 5. max. radius for mass calculations
# 6. optical parameters
#
"# All lines which don't start with a ""#"" have to be filled in."
output 中出现不必要的引号(例如:最后一行)。 如何解决这个问题?
实际上,我可以通过使用带制表符的分隔符保存来解决它。
df.to_csv('out.csv',index=False,sep='\t')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.