【问题标题】:Convert excel file to pipe delimited file in python在python中将excel文件转换为管道分隔文件
【发布时间】:2016-07-26 08:01:02
【问题描述】:

我知道我们可以使用 python 的 csv 模块将 CSV 文件编写为管道分隔文件,但是我想将我的 excel 文件编写为管道分隔的文本文件,是否有类似于 csv 模块的模块可以帮助我实现这一点?

【问题讨论】:

标签: python-2.7 xlsx


【解决方案1】:

你可以使用熊猫模块

# Import modules
import pandas as pd

# read the content of your Excel file into a dataframe
df_sheet  = pd.read_excel('test.xlsx', index_col=0) 

# write the content of your dataframe into a csv file with the right delimiter
df_sheet.to_csv ("test.csv", sep="|")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-05-31
    • 2015-04-21
    • 1970-01-01
    • 2023-03-15
    • 2014-10-15
    • 1970-01-01
    • 2016-07-19
    相关资源
    最近更新 更多