<jupyter_start><jupyter_text>Install shaystack module from test.pypi.org<jupyter_code>import sys
!{sys.executable} -m pip install shaystack<jupyter_output><empty_output><jupyter_text>Import modules<jupyter_code>import shaystack
import datetime<jupyter_output><empty_output><jupyter_text>Create a grid with metadata and columns<jupyter_code>g = shaystack.Grid()
g.metadata['aMarker'] = shaystack.MARKER
g.metadata['today'] = datetime.date.today()
g.column['firstColumn'] = {'metaData':'in no particular order', 'abc': 123}
g.column['secondColumn'] = {}<jupyter_output><empty_output><jupyter_text>The same with the constructor<jupyter_code>g = shaystack.Grid(metadata=
                     {
                         "aMarker":shaystack.MARKER,
                         "today":datetime.date.today()
                     },
                    columns=
                     {
                         "firstColumn":{'metaData':'in no particular order', 'abc': 123},
                         "secondColumn": {}
                     }
                    )<jupyter_output><empty_output><jupyter_text>Add some entities<jupyter_code>g.extend([
    {'firstColumn': shaystack.Quantity(154, 'kg'), 'secondColumn': 'and counting'},
    {'firstColumn': shaystack.MARKER, 'secondColumn': 'supported on Python 3.7+'},
    {'firstColumn': shaystack.Coordinate(-27.4725,153.003),
     'secondColumn': 'Made in Australia from local and imported ingredients'},
])<jupyter_output><empty_output><jupyter_text>Dump to zinc format<jupyter_code>print(shaystack.dump(g))<jupyter_output><empty_output><jupyter_text>Dump to JSON<jupyter_code>import json
json.loads(shaystack.dump(g,mode=shaystack.MODE_JSON))<jupyter_output><empty_output><jupyter_text>Load haystack file from URL<jupyter_code>import urllib
base_url= "https://shaystack.s3.eu-west-3.amazonaws.com/"
url = base_url + "carytown.zinc"
with urllib.request.urlopen(url) as f:
    g = shaystack.parse(f.read(),shaystack.MODE_ZINC)<jupyter_output><empty_output><jupyter_text>Filter some entity<jupyter_code>site = g.filter("site")[0]
site<jupyter_output><empty_output><jupyter_text>Read time-series<jupyter_code>with_his = g.filter("his")[0]
ts_uri = base_url + with_his["hisURI"]
with urllib.request.urlopen(ts_uri) as f:
    ts = shaystack.parse(f.read(),shaystack.MODE_ZINC)
    print(ts)  # Print associated time-series<jupyter_output><empty_output><jupyter_text>Save grid<jupyter_code>with open("ontology.csv","w") as f:
    f.write(shaystack.dump(g,shaystack.MODE_CSV))
with open("ontology.json","w") as f:
    f.write(shaystack.dump(g,shaystack.MODE_JSON))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13856109630757518, 'fraction_numerical': 0.010277883517320136, 'mean_word_length': 4.567796610169491, 'pattern_counts': {'":': 4, '<': 45, '<?xml version=': 0, '>': 45, 'https://': 1, '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': '11', 'dir': 'jupyter-structured-clean-dedup', 'id': '88437', 'license': 'BSD-2-Clause', 'n_tokens_mistral': 952, 'n_tokens_neox': 914, 'n_words': 130, 'path': 'haystack.ipynb', 'repo_name': 'flzara/shaystack', 'size': '2627'}