Python实现txt转Excel(坐标)

python 复制代码
import pandas as pd

def txt_to_excel(txt_file, excel_file):
    # 读取 txt 文件
    with open(txt_file, 'r') as f:
        lines = f.readlines()

    # 将每行数据分割成多个单元格
    data = []
    for line in lines:
        row = line.strip().split(' ')
        data.append(row)

    # 将数据保存到 Excel 文件
    df = pd.DataFrame(data)
    df.to_excel(excel_file, index=False, header=False)

# 文件名
file_name = '100-100圆柱'

# 调用函数,传递变量作为参数
txt_to_excel(file_name+'.txt', file_name+'.xlsx')

图示

相关推荐
鸟儿不吃草12 分钟前
安卓实现左右布局聊天界面
android·开发语言·python
mr_LuoWei200920 分钟前
类似CASS for autoCAD的平基土石方三维计算工具基本完成
python·三维地形图
alwaysrun32 分钟前
Python自动提取邮件订阅链接并解析
python·url·邮件·ai提取
何中应33 分钟前
Conda安装&使用
python·conda·python3.11
无敌昊哥战神43 分钟前
【LeetCode 37】解数独 (Sudoku Solver) —— 回溯法详解 (Python/C/C++)
c语言·c++·python·算法·leetcode
风流 少年1 小时前
Python Web框架:FastAPI
前端·python·fastapi
Qres8211 小时前
Rabrg/artificial-life test
python·模拟
财经资讯数据_灵砚智能1 小时前
基于全球经济类多源新闻的NLP情感分析与数据可视化(夜间-次晨)2026年5月1日
大数据·人工智能·python·信息可视化·自然语言处理
好奇龙猫1 小时前
[大学院ーpython-base learning3: python and recommendation system ]
开发语言·python
篮子里的玫瑰1 小时前
Python与网络爬虫——字典与集合
开发语言·python