直接贴代码啦:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#coding=utf-8 import pandas as pd def arff_to_csv(fpath): #读取arff数据 if fpath.find( '.arff' ) < 0 : print ( 'the file is nott .arff file' ) return f = open (fpath) lines = f.readlines() content = [] for l in lines: content.append(l) datas = [] for c in content: cs = c.split( ',' ) datas.append(cs) #将数据存入csv文件中 df = pd.DataFrame(data = datas,index = None ,columns = None ) filename = fpath[:fpath.find( '.arff' )] + '.csv' df.to_csv(filename,index = None ) |
以上这篇python 利用pandas将arff文件转csv文件的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持服务器之家。
原文链接:https://blog.csdn.net/xzfreewind/article/details/79587726