python将pandas datarame保存为txt文件的实例
作者:曳落 时间:2021-11-17 06:21:51
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
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
ASP动态包含文件的改进方法
960 Grid System 基本原理及使用方法
Asp用正则表达式获取文章中的所有图片地址
django有外键关系的两张表如何相互查找
解析:轻松了解 MySQL中损坏的MyISAM表
python支持多继承吗
js弹出新窗口而不会被浏览器阻止的方法
Python实现提取给定网页内的所有链接
![](https://img.aspxhome.com/file/2023/4/80814_0s.webp)
将keras的h5模型转换为tensorflow的pb模型操作
![](https://img.aspxhome.com/file/2023/1/81841_0s.jpg)
Python实现乱序文件重新命名编号
![](https://img.aspxhome.com/file/2023/3/75313_0s.png)
HTML5本地存储初探(二)
![](https://img.aspxhome.com/file/UploadPic/20103/7/20100131-rmki9pjq85xy9nbt436gkdfb7i-94s.png)
使用python调用zxing库生成二维码图片详解
![](https://img.aspxhome.com/file/2023/7/90787_0s.png)
实现MySQL远程访问办法
Python将图片批量从png格式转换至WebP格式
![](https://img.aspxhome.com/file/2023/2/76942_0s.png)
python 读取、写入txt文件的示例
![](https://img.aspxhome.com/file/2023/7/63237_0s.png)
java往php传数据操作方法
![](https://img.aspxhome.com/file/2023/2/63502_0s.png)
opencv调用yolov3模型深度学习目标检测实例详解
![](https://img.aspxhome.com/file/2023/1/95201_0s.jpg)
Python+Seaborn绘制分布图的示例详解
![](https://img.aspxhome.com/file/2023/2/98872_0s.png)