I have an xml file which i convert it with xmltodict into a json object. I want to import that json object (with mongoimport) without first store it in a json file. Is it a way to achivie this or mongoimport feeds only with csv, tsv or json files? Below is the code that I have written and when I run it I take this error: Error parsing command line options: error parsing postional arguments: provide only one file name and only one mongodb connection string When I first store the json object into a file an pass this file as an argument instead of the json object, works fine
import os, json
import xmltodict
with open('test.xml', 'r') as f:
data = xmltodict.parse(f.read())
json_data = json.dumps(data)
os.system(f'mongoimport --host myserversip --port 27017 --db test --collection items --file{json_data}')