archivesunleashed / auk-notebooks

Jupyter notebooks to assist in creating additional analysis and visualizations of Archives Unleashed Cloud derivatives.
https://cloud.archivesunleashed.org
Other
11 stars 5 forks source link

write_output doesn't work #54

Closed ianmilligan1 closed 5 years ago

ianmilligan1 commented 5 years ago

As part of #44 I was re-working the file outputs, and we discovered that the file outputs don't work.

Here's the write_output function from au_notebook [repo]

    def write_output(self, stdout, results):
        """ Writes results to file.
        :param stdout: Filepath for file.
        :param results: A list of results.
        :return: None.
        """
        try:
            with open(filename, "w") as output:
                for value in results:
                    output_file_write(str(value))
        except:
            print("Error writing the file.")

When it's called, you get

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-24-be93de9f0824> in <module>()
----> 1 au_notebook.write_output('./filtered-by-year.txt', year_results)

TypeError: write_output() missing 1 required positional argument: 'results'

As part of the fix, it'd be great if something like this would work out of the box:

au_notebook.write_output('./filtered-by-year.txt', year_results)
ruebot commented 5 years ago

Tested on my end, and changed it to the missing import prefix nb.write_output(filename, year_results). It results in the error message in the function: Error writing the file.

greebie commented 5 years ago

Once completed there will be a small PR here as well to switch to nb.write_output().

ruebot commented 5 years ago

au_notebook-0.0.3 cut: https://pypi.org/project/au-notebook/

@greebie make sure you update requirements.txt, and the README when you do this PR.

ianmilligan1 commented 5 years ago

Closed with 256db8e87d0cf80c392623fbda33a6d50191d633 (#55)