def do_write(self, filename): """ Writes the results into the specified file usage: write <filename> """ print("Writing the contents to " + filename) csvWriter = CSVWriter() print("Writing the results") print("Found %i results" % len(self.results)) try: csvWriter.write_to_file(filename, self.results) print("All results written to file succesfully!") except PermissionError: print("\nNo permission to write to file. Might it be accidently left open?")
__author__ = "Janne" import xml.etree.ElementTree as ET from ieeeprocessor import IEEEProcessor from csv_writer import CSVWriter # Construct the tree by parsing the XML file tree = ET.parse("searchresult.xml") # Then, get the root of the tree root = tree.getroot() # Then, parse it to Entry processor = IEEEProcessor() processor.ProcessSearchResults(root) print("Found %i entries" % len(processor.entries)) # Okay, now we need to process all the entries into a .csv file # Initialize the csv writer csvWriter = CSVWriter() csvWriter.write_to_file("test.csv", processor.entries)