gentzkow / template_archive

19 stars 36 forks source link

PR for #85: Ideate new approach to formatting table/diagram structure in template #97

Open snairdesai opened 9 months ago

snairdesai commented 9 months ago

Closes #85.

The purpose of this PR is to extend the template architecture to enable native Excel to PDF conversions. See the issue thread for additional details, and in particular https://github.com/gentzkow/template/issues/85#issuecomment-1819927895 for the final proposal of the workflow. The core workhorse function is export_excel_tables() in gslab_make() (find the development version here).

@jc-cisneros has been assigned as a reviewer. To review this PR, please complete the following:

Thanks for the review @jc-cisneros!

jc-cisneros commented 7 months ago

@snairdesai, confirming a successful run on a Mac machine. Some files don't match the ones on this branch. I will push what I have on my end, but feel free to revert/overwrite if needed.

jc-cisneros commented 7 months ago

@snairdesai, I think the current README is too lengthy. My suggestion would be to remove or push down any details on context or extra information. As a user, the first section I want to see is a clear intuition of the input and output, concrete steps for implementation, and only relevant warnings. I would remove all the details on the spreadsheet linking and the description of the function arguments (this should be documented in the code itself).

snairdesai commented 7 months ago

@jc-cisneros Sounds good, and I agree. I'll remove the details on linking and function arguments. In the PR, can you use the "suggestion" tag to delete any other lines you feel are irrelevant? I can review and we'll discuss your proposed changes.

snairdesai commented 7 months ago

@jc-cisneros: Latest version for your comments pushed in this commit.

jc-cisneros commented 7 months ago

Thanks @snairdesai! The README looks less cluttered now. Will test this on a Windows machine.

jc-cisneros commented 7 months ago

@snairdesai, I got the following error on Windows (also note that you need to run the terminal as administrator to get the right permission level):

\juanc\OneDrive\Desktop\template\paper_slides\code\slides.tex"`
pdf-crop-margins not found. Installing it now...
pdf-crop-margins has been successfully installed.
Error in `export_excel_tables()` for gs_primary: list index out of range

Traceback (most recent call last):
  File "C:\Users\juanc\OneDrive\Desktop\template\paper_slides\..\lib\gslab_make\gslab_make\run_program.py", line 1268, in export_excel_tables
    worksheet = workbook.Worksheets[2]
                ~~~~~~~~~~~~~~~~~~~^^^
  File "C:\Users\juanc\miniconda3\envs\template\Lib\site-packages\win32com\client\dynamic.py", line 322, in __getitem__
    return self._get_good_object_(self._enum_.__getitem__(index))
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\juanc\miniconda3\envs\template\Lib\site-packages\win32com\client\util.py", line 41, in __getitem__
    return self.__GetIndex(index)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\juanc\miniconda3\envs\template\Lib\site-packages\win32com\client\util.py", line 65, in __GetIndex
    raise IndexError("list index out of range")
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\juanc\OneDrive\Desktop\template\paper_slides\make.py", line 52, in <module>
    gs.export_excel_tables(PATHS, template = 'gs_primary', scalar = 'gs_primary_scalars.xlsx')
  File "C:\Users\juanc\OneDrive\Desktop\template\paper_slides\..\lib\gslab_make\gslab_make\run_program.py", line 1294, in export_excel_tables
    raise RuntimeError(error_message)
RuntimeError: Error in `export_excel_tables()` for gs_primary: list index out of range
snairdesai commented 7 months ago

Thanks @jc-cisneros, that is helpful. I'll try testing this on the lab Windows and see if I can debug.