<jupyter_start><jupyter_text>Chapter 8 : Extend the framework One can add Sources and Sinks to the framework.Just extend the corresponding classes.You can add a Source that is dedicated to your custom data and your custom agent.`SourceMicrosoftExcel` is given as an example.Let's say you've just created your own Source capable of parsing xlsx files and yielding CSV-like rows from it.<jupyter_code>from pyngsi.sources.more_sources import SourceMicrosoftExcel

src = SourceMicrosoftExcel("files/room.xlsx")

for row in src:
    print(row)<jupyter_output><empty_output><jupyter_text>Now you'd like to use it in all situations, especially if the xlsx files you're interested in are remotely.You'll have to register the source.<jupyter_code>from pyngsi.sources.more_sources import SourceMicrosoftExcel

# global registering
Source.register(SourceMicrosoftExcel)

# for the purpose of the tutorial the file room.xlsx is stored locally
src = Source.from_glob("files/*.xlsx")

for row in src:
    print(row)

Source.unregister()<jupyter_output><empty_output><jupyter_text>As an alternative you might want to register only the xlsx extension, allowing to handle multiple formats at the same time.<jupyter_code>from pyngsi.sources.source import Source
from pyngsi.sources.more_sources import SourceMicrosoftExcel

# register extension
Source.register_extension("xlsx", SourceMicrosoftExcel)

# for the purpose of the tutorial the files room.xlsx and room.csv are stored locally
src = Source.from_glob("files/room.*")

for row in src:
    print(row)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.06751592356687898, 'fraction_numerical': 0.0006369426751592356, 'mean_word_length': 5.920704845814978, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '275133', 'license': 'Apache-2.0', 'n_tokens_mistral': 463, 'n_tokens_neox': 441, 'n_words': 167, 'path': 'chapter9_extend.ipynb', 'repo_name': 'pixel-ports/pyngsi-tutorial', 'size': '1570'}