How do I write to an ARFF file using the LIAC-ARFF package in Python?
I want to load an ARFF file in python, then change some values ββand then save the changes to the file. I am using the package LIAC-ARFF
( https://pypi.python.org/pypi/liac-arff ). I have uploaded an ARFF file with the following lines of code:
import arff
data = arff.load(open(FILE_NAME, 'rb'))
After manipulating some values ββinternally data
, I want to write data
to another ARFF file. Any solution?
source to share
Use the following code:
import arff data = arff.load(open(FILE_NAME, 'rb')) f = open(outputfilename, 'wb') arff.dump(data, f) f.close()
In the description, LICA-ARFF
you see a method dump
that is serialized to a file, but this is wrong. It just writes the object as a text file. Serialization means storing the entire object, so the output file is binary, not text.
source to share