# Add the tables to the DocumentStore
import json
from haystack import Document
import pandas as pd
def read_tables(filename):
processed_tables = []
with open(filename) as tables:
tables = json.load(tables)
for key, table in tables.items():
current_columns = table["header"]
current_rows = table["data"]
current_df = pd.DataFrame(columns=current_columns, data=current_rows)
document = Document(content=current_df, content_type="table", id=key)
processed_tables.append(document)
return processed_tables
tables = read_tables(f"{doc_dir}/tables.json")
document_store.write_documents(tables, index=document_index)
# Showing content field and meta field of one of the Documents of content_type 'table'
print(tables[0].content)
print(tables[0].meta)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter