From 8183dc845d679b3c4076cc3d3e8235a4a89703a3 Mon Sep 17 00:00:00 2001 From: Sateesh Kavuri Date: Mon, 8 Jun 2015 17:02:35 +0530 Subject: [PATCH] Fixed bug related to dumping json to arff The arff library takes a filename(string) as input and not a file handle. Fixed by removing the file handle and passing the filename The converter has a bug that it does not convert json to arff properly This needs to be fixed further Signed-off-by: Sateesh Kavuri --- arff_parser.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/arff_parser.py b/arff_parser.py index b412980..0329661 100755 --- a/arff_parser.py +++ b/arff_parser.py @@ -182,7 +182,6 @@ def makeArff(filename,handle,opts): dataOut= [] attributesOut=[] relation = filename.split(".")[0] - outfile = open(handle,'w') with open(filename) as data_file: dataIn = json.load(data_file) for entry in dataIn["data"]: @@ -195,7 +194,7 @@ def makeArff(filename,handle,opts): values.append(entry[value]) dataOut.append(values) attributesOut.append(attributes) - arff.dump(outfile, dataOut, relation=relation, names=attributesOut[0]) + arff.dump(handle, dataOut, relation=relation, names=attributesOut[0]) def show_schema(schema): """debug""" @@ -209,4 +208,4 @@ def main(): for filename in file_args: process(filename, opts) -main() \ No newline at end of file +main()