Skip to content

Commit

Permalink
Merge branch 'main' of github.com:alphanome-ai/sec-parser
Browse files Browse the repository at this point in the history
  • Loading branch information
Elijas committed Dec 22, 2023
2 parents 322d8b5 + 3502bb4 commit a7868e8
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions .devcontainer/example.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
# NOTE:
# For more examples and advanced usage of `sec-parser`, refer to the following resources:
# - [User Guide](https://sec-parser.readthedocs.io/en/latest/notebooks/user_guide.html)
# - [Developer Guide](https://sec-parser.readthedocs.io/en/latest/notebooks/developer_guide.html)
# - [Documentation](https://sec-parser.rtfd.io)
# - User Guide:
# https://sec-parser.readthedocs.io/en/latest/notebooks/user_guide.html
# - Developer Guide
# https://sec-parser.readthedocs.io/en/latest/notebooks/developer_guide.html
# - Documentation:
# https://sec-parser.readthedocs.io/en/latest/

from sec_downloader import Downloader

import sec_parser as sp

# Utility function to make the example code a bit more compact
def print_first_n_lines(text: str, *, n: int):
print("\n".join(text.split("\n")[:n]), "...", sep="\n")


# Initialize the downloader with your company name and email
dl = Downloader("MyCompanyName", "[email protected]")

# Download the latest 10-Q filing for Apple
html = dl.get_filing_html(ticker="AAPL", form="10-Q")


# Utility function to make the example code a bit more compact
def print_first_n_lines(text: str, *, n: int):
print("\n".join(text.split("\n")[:n]), "...", sep="\n")


# Now, we can parse the filing HTML into a list of semantic elements:
elements: list = sp.Edgar10QParser().parse(html)

demo_output: str = sp.render(elements)
print_first_n_lines(demo_output, n=7)

# We can also construct a semantic tree to allow for easy filtering by parent sections:
tree = sp.TreeBuilder().build(elements)
demo_output: str = sp.render(tree)
print_first_n_lines(demo_output, n=7)

0 comments on commit a7868e8

Please sign in to comment.