Execute Python with IDEAScript
Forums
Hello friends,
I'm having trouble running a .py file with IDEA, I need to import 25 million XML files into IDEA, we created a macro that automatically imports the files for us, but it takes a long time to join the databases in IDEA and organize them, we came up with doing a PYTHON file that allows us to do this faster and in a single document, to import into IDEA later.
the file is the following:
import xml.etree.ElementTree as ET
import os
import glob
carpeta = 'ejes'
archivos_xml = glob.glob(carpeta + '\*.xml')
trees = []
for archivo in archivos_xml:
tree = ET.parse(archivo)
trees.append(tree)
combined_tree = ET.ElementTree()
combined_root = ET.Element('root')
combined_tree._setroot(combined_root)
for tree in trees:
root = tree.getroot()
for element in root:
combined_root.append(element)
combined_tree.write('archivo_combinado2.xml')
The code works correctly, but when I run it in IDEA I get 2 errors, if I run it in a folder outside of IDEA it tells me that the address was not found.
If I run it in the IDEA project folders as the documentation indicates, it always responds that there was an error on line 2, regardless of what is written on line 2
I need guidance to be able to execute .py files in IDEA correctly.
Hi Alexander,
Hi Alexander,
This was a strange one, I tried coping your code and I was also getting errors. So I tried creating it one line at a time and then testing each one and it worked. I have attached the files that I created. I don't know why you were getting errrors.