Skip to content

Commit

Permalink
Switch from xlsxwriter to openpyxl
Browse files Browse the repository at this point in the history
  • Loading branch information
tw4l committed Aug 5, 2023
1 parent b20c51d commit c581f25
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
16 changes: 6 additions & 10 deletions diskimageprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
import datetime
import itertools
import logging
import openpyxl
import os
import shutil
import stat
import subprocess
import sys
import time
import xlsxwriter

from disk_image_toolkit import DiskImage
from disk_image_toolkit.dfxml import objects
Expand Down Expand Up @@ -279,13 +279,8 @@ def create_aspace_excel_sheet(args, sips, volumes, logger):
except OSError as err:
logger.error(f"Error setting permissions: {err}")

workbook = xlsxwriter.Workbook(xlsx_path, {"strings_to_numbers": True})

# TODO: Remove when no longer necessary
worksheets = workbook.worksheets()
logger.info("Worksheets: {}".format(",".join(worksheets)))

worksheet = workbook.get_worksheet_by_name("Data")
workbook = openpyxl.load_workbook(filename=xlsx_path)
worksheet = workbook.get_sheet_by_name("Data")

# TODO: Remove when no longer necessary
if worksheet is None:
Expand Down Expand Up @@ -367,7 +362,7 @@ def create_aspace_excel_sheet(args, sips, volumes, logger):
INDEX_SCOPE_CONTENTS
] = "Error gathering statistics from SIP directory"

worksheet.write(row_to_write)
worksheet.append(row_to_write)

logger.error("Unable to read DFXML files for {}".format(sip_path))
continue
Expand Down Expand Up @@ -425,10 +420,11 @@ def create_aspace_excel_sheet(args, sips, volumes, logger):
row_to_write[INDEX_SIZE] = human_readable_size(total_bytes)
row_to_write[INDEX_SCOPE_CONTENTS] = scope_content

worksheet.write(row_to_write)
worksheet.append(row_to_write)

logger.info("Described %s successfully." % (sip_path))

workbook.save()
workbook.close()

logger.info("ArchivesSpace description XLSX created.")
Expand Down
2 changes: 1 addition & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
bagit>=1.7.0
brunnhilde>=1.9.1
xlsxwriter>=3.1.2
openpyxl>=3.1.2

0 comments on commit c581f25

Please sign in to comment.