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

标签:python,pandas,datarame,txt
0
投稿

猜你喜欢

  • ASP动态包含文件的改进方法

    2009-01-05 12:22:00
  • 960 Grid System 基本原理及使用方法

    2009-02-28 13:35:00
  • Asp用正则表达式获取文章中的所有图片地址

    2010-07-17 13:11:00
  • django有外键关系的两张表如何相互查找

    2023-10-19 06:08:45
  • 解析:轻松了解 MySQL中损坏的MyISAM表

    2009-02-23 17:30:00
  • python支持多继承吗

    2023-10-14 11:22:48
  • js弹出新窗口而不会被浏览器阻止的方法

    2010-04-06 12:38:00
  • Python实现提取给定网页内的所有链接

    2022-03-29 19:01:11
  • 将keras的h5模型转换为tensorflow的pb模型操作

    2021-06-05 15:14:06
  • Python实现乱序文件重新命名编号

    2021-05-20 09:07:04
  • HTML5本地存储初探(二)

    2010-03-07 15:47:00
  • 使用python调用zxing库生成二维码图片详解

    2022-03-19 06:41:09
  • 实现MySQL远程访问办法

    2010-11-25 17:17:00
  • Python将图片批量从png格式转换至WebP格式

    2023-01-11 00:27:49
  • python 读取、写入txt文件的示例

    2023-09-29 22:04:18
  • java往php传数据操作方法

    2023-10-27 17:51:48
  • opencv调用yolov3模型深度学习目标检测实例详解

    2022-04-30 19:37:55
  • Python+Seaborn绘制分布图的示例详解

    2021-08-14 16:51:29
  • 一文搞懂Python中is和==的区别

    2023-11-15 09:42:27
  • asp form 表单验证函数

    2011-04-04 11:10:00
  • asp之家 网络编程 m.aspxhome.com