From 9bec7bbd8f3e284df94eb2e7a9a16185f8ae97e5 Mon Sep 17 00:00:00 2001 From: allfro Date: Sun, 10 Feb 2013 02:39:02 -0500 Subject: [PATCH] Fixed bug related to columns with new lines --- src/canari/commands/mtgx2csv.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/canari/commands/mtgx2csv.py b/src/canari/commands/mtgx2csv.py index 4db41f9..011f6f4 100644 --- a/src/canari/commands/mtgx2csv.py +++ b/src/canari/commands/mtgx2csv.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -from common import cmd_name +from common import cmd_name, to_utf8 from xml.etree.cElementTree import XML from argparse import ArgumentParser @@ -12,7 +12,7 @@ __copyright__ = 'Copyright 2012, Canari Project' __credits__ = [] __license__ = 'GPL' -__version__ = '0.1' +__version__ = '0.2' __maintainer__ = 'Nadeem Douba' __email__ = 'ndouba@gmail.com' __status__ = 'Development' @@ -53,10 +53,10 @@ def run(args): csv = open(f.split('/')[1].split('.')[0] + '.csv', 'w') xml = XML(zip.open(f).read()) for e in xml.findall('{http://graphml.graphdrawing.org/xmlns}graph/{http://graphml.graphdrawing.org/xmlns}node/{http://graphml.graphdrawing.org/xmlns}data/{http://maltego.paterva.com/xml/mtgx}MaltegoEntity'): - csv.write(('"Entity Type=%s",' % e.get('type')).strip()) + csv.write(to_utf8(('"Entity Type=%s",' % e.get('type')).strip())) for prop in e.findall('{http://maltego.paterva.com/xml/mtgx}Properties/{http://maltego.paterva.com/xml/mtgx}Property'): value = prop.find('{http://maltego.paterva.com/xml/mtgx}Value').text or '' if '"' in value: value.replace('"', '""') - csv.write(('"%s=%s",' % (prop.get('displayName'), value)).strip()) + csv.write(to_utf8(('"%s=%s",' % (prop.get('displayName'), value)).strip().replace('\n', ', '))) csv.write('\n') \ No newline at end of file -- 2.45.1