Created on Mon Jun 15 09:44:49 2015
@author: Chaofn
"""
def loadDataSet(fileName):
fr=open(fileName)
fp=open('D:/01.test','w')
"""
curLine的类型为list
去除数据集中的第一列
添加换行符
将列表类型转化成字符串类型
"""
for line in fr.readlines():
curLine=line.strip().split(',')
del curLine[0]
curLine.append('\n')
strLine=' '.join(curLine)
fp.write(strLine)
fp.close()
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 21 13:03:19 2015
@author: chaofan
"""
fr=open('G:/1aba.txt')
fw=open('G:/1aba_new.txt','w')
for line in fr.readlines():
lineList=[]
lineList.extend([line[7:10],line[11],line[13],line[35:38],'\n'])
fw.write(' '.join(lineList))
fw.close()