2

I am trying to convert an XML file to MarkDown but I can't find an example of converting a python dict. Here is my code:

import pypandoc
import xmltodict 
import json 

datadict = open("/home/.../FIX44.xml") 
dic = xmltodict.parse(datadict.read()) 

jsondump = json.dumps(dic) 
#print jsondump 

output = pypandoc.convert(jsondump, 'md', format='json', outputfile = 'test.md') 
assert output == ""

When I try to run this I get:

RuntimeError: Pandoc died with exitcode "1" during conversion

das-g
  • 9,718
  • 4
  • 38
  • 80
Rory Harrison
  • 117
  • 10
  • 2
    I think importing `pypandoc as pd` is a bit confusing. `pd` is usually reserved for `pandas`... – CIsForCookies Aug 22 '18 at 12:31
  • 1
    Thanks @CIsForCookies, I'm new to Python, will correct and reserve it in the future – Rory Harrison Aug 22 '18 at 12:34
  • 1
    You cannot take any XML file, convert it to some JSON and expect that to be a representation of pandoc's internal document model. You should probably post a part of that XML file, but you'll most probably have to write a script that converts it to HTML or similar, before you can use pandoc to convert it to markdown. – mb21 Aug 22 '18 at 13:35

0 Answers0