python 数据处理 对txt文件进行数据处理
2024-10-19 11:41:12
数据:
对txt文件进行数据处理:
txt_file_path = "basic_info.txt"
write_txt_file_path = "basic_info1.txt"
def write_txt_file():
if os.path.exists(txt_file_path) is False:
return
with open(txt_file_path,'r') as r_file:
for row in r_file:
list = row.split("\t")
# print("用\\t分割行的结果:{}".format(list))
# print("待分割的列:{}".format(list[2]))
col = list[2]
res = col[2:-2].split('|')
# print("对此列进行分割的结果:{}".format(res))
#将分割结果写入新的文件中
with open(write_txt_file_path,'a') as w_file:
w_file.write(' '.join(res))
w_file.write('\n')
#break if __name__ == "__main__":
write_txt_file()
最新文章
- 高性能JavaScript--加载和执行(简要学习笔记一)
- 【JWT】JWT+HA256加密 Token验证
- ";递归";实现";约瑟夫环";,";汉诺塔";
- Step deep into GLSL
- 13款精彩实用的最新jQuery插件
- BZOJ 1560 火星藏宝图(DP)
- Visual Assist X在Windows 8.1下出现中文乱码的解决方法
- hdu_5719_Arrange(脑洞题)
- java特征
- 随机采样和随机模拟:吉布斯采样Gibbs Sampling实现高斯分布参数推断
- 机器学习入门18 - 生产机器学习系统(Production ML Systems)
- 读取Excel,单元格内容大于255个字符自动被截取的问题
- 2019.4.24 一题(CF 809E)——推式子+虚树
- vc++ openssl 程序签名
- HTML学习总结(作业五)
- Unity 多人网络连接
- LeetCode 976 Largest Perimeter Triangle 解题报告
- 2018.12.31 bzoj3771: Triple(生成函数+fft+容斥原理)
- virtualenv虚拟环境安装不同版本的django
- java classpath作用
热门文章
- iOS开发-真机调试遇到“The executable was signed with invalid entitlements.
- Python中.npz文件的读取
- win10上安装mysql8(installer方式)并创建用户开启远程连接
- 【原】nginx配置文件
- 什么是Device ID?
- cookie、session、localStorage、sessionStorage的区别
- 使用mybase、Typora搭配坚果云实现个人云笔记
- 2016 年 31 款轻量高效的开源 JavaScript 插件和库
- 你知道HTTP协议的ETag是干什么的吗?
- 吴裕雄 Bootstrap 前端框架开发——Bootstrap 按钮:用于要弹出信息的按钮