python 读文件 写文件 字符串操作 LIBSVM格式数据转换
来源:互联网 发布:仙剑奇侠传mac版 编辑:程序博客网 时间:2024/04/29 13:50
利用python脚本将数据转换成符合LIBSVM格式的数据
#coding=utf-8from sys import argvscript, input, output = argvtxt = open(input,'r')svm_data = open(output,'w')for line in txt.readlines(): features = line.split(',') num = len(features) svm_format = features[num-2] for i in range(1,num-3): svm_format = "%s %d:%s" % (svm_format,i,features[i]) svm_format = svm_format + '\n' svm_data.write(svm_format) print svm_formattxt.close()svm_data.close()
0 0
- python 读文件 写文件 字符串操作 LIBSVM格式数据转换
- python 读/写文件操作
- Python文件写操作
- python文件数据操作
- python将json格式的数据转换成文本格式的数据或sql文件
- python csv文件写操作
- python解决数据预处理:将KDDCPU99数据格式转换成libsvm可读的格式
- fstream方式操作文件(格式转换)
- python转换格式,Matlab读取文件
- Python 批量转换文件编码格式
- Python字符串格式转换
- Delphi文件操作-读文件-写文件-操作文件
- Python open()函数文件打开、读、写操作详解
- Python open()函数文件打开、读、写操作 0602
- python 写xml文件的操作
- python写xml文件的操作
- 文件操作 写文件
- python写数据到外部文件
- 并发控制的一个实现
- 范数
- Block很简单,就像delegate的简化版
- 人月神话读书笔记(1)----焦油坑
- ViewPagerIndcatior 的使用
- python 读文件 写文件 字符串操作 LIBSVM格式数据转换
- CodeForces 567CGeometric Progression
- jdbc.properties
- github clone速度慢的解决方案
- ios字典功能UIReferenceLibraryViewController
- hdu 5230(整数划分,dp)
- 判定覆盖和条件覆盖
- 有一个会做饭的男朋友幸福么?
- python爬虫1