网络编程
位置:首页>> 网络编程>> Python编程>> python将pandas datarame保存为txt文件的实例

python将pandas datarame保存为txt文件的实例

作者:曳落  发布时间:2021-11-17 06:21:51 

标签:python,pandas,datarame,txt

CSV means Comma Separated Values. It is plain text (ansi).

The CSV ("Comma Separated Value") file format is often used to exchange data between disparate applications. The file format, as it is used in Microsoft Excel, has become a pseudo standard throughout the industry, even among non-Microsoft platforms.

TXT is not really a file format, and it could mean multiple things in different contexts. Generally you export tables in either CSV (comma separated values) or TSV (tab separated values). Which you should choose depends mainly on your data: if your data has commas in it but not tabs, you should go for TSV.


# -*- coding: UTF-8 -*-
import sys
import json
reload(sys)
sys.setdefaultencoding('utf-8')

import pandas as pd
import numpy as np

#读取excel保存成txt格式
excel_file = pd.read_excel("text.xlsx")
excel_file.to_csv('excel2txt.txt', sep='\t', index=False)

参考:https://stackoverflow.com/questions/41428539/data-frame-to-file-txt-python/41514539

来源:https://blog.csdn.net/xieganyu3460/article/details/81810306

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com