]> git.nothing2do.fr Git - get-hack-src.git/commitdiff
Fixed bug related to columns with new lines
authorallfro <ndouba@gmail.com>
Sun, 10 Feb 2013 07:39:02 +0000 (02:39 -0500)
committerallfro <ndouba@gmail.com>
Sun, 10 Feb 2013 07:39:02 +0000 (02:39 -0500)
src/canari/commands/mtgx2csv.py

index 4db41f9db2eed5101aa98032d2363c291087e018..011f6f4b44418b802eec23d72ed7bc201e227543 100644 (file)
@@ -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