Updates to how output files are named cause errors to throw during the execution of conv_html_to_markdown.py.
Solution:
Import glob: At the top of conv_html_to_markdown.py, add import glob to use the glob module for file pattern matching.
Update load_json Function:
Rename it to load_json_files to reflect its new functionality.
Use glob.glob to find all files matching the output-*.json pattern.
Iterate over these files, load their contents, and aggregate the data.
import glob
def load_json_files(pattern):
"""
Load data from multiple JSON files matching a pattern.
Args:
pattern (str): Glob pattern to match files.
Returns:
list: Aggregated data from all matched files.
"""
aggregated_data = []
for file_path in glob.glob(pattern):
with open(file_path, "r", encoding="utf-8") as file:
aggregated_data.extend(json.load(file))
return aggregated_data
def main():
# ... existing code ...
try:
# Load data from all output JSON files
original_data = load_json_files("output-*.json")
# ... rest of the existing code ...
Updates to how output files are named cause errors to throw during the execution of
conv_html_to_markdown.py
.Solution:
Import glob: At the top of
conv_html_to_markdown.py
, add import glob to use the glob module for file pattern matching.Update load_json Function: