Git Product home page Git Product logo

Comments (1)

Elijas avatar Elijas commented on June 1, 2024

Hey @seanroades, thanks for reaching out!

Note

For most up to date version of this answer, check out https://github.com/Elijas/sec-parser-exploration/blob/main/02_other_sec_form_types.ipynb

How do I parse other form types with sec-parser, such as 10-K, 8-K, S-1, etc.?

As of April 2023, sec-parser supports parsing various SEC form types beyond just 10-Q, such as 10-K, 8-K, S-1, and more. Basically, it supports parsing any structured text forms.

However, currently only parsing 10-Q top level section types is supported.

This gives us two methods to parse other form types with sec-parser:

  1. Ignore the warnings from the parsing step that identifies the 10-Q top level section types
  2. Skip the parsing step that identifies the 10-Q top level section types

Method 1: Ignore warnings from the parsing step that identifies the 10Q top level section types

import warnings
from sec_downloader import Downloader
import sec_parser as sp

dl = Downloader("MyCompanyName", "[email protected]")
html = dl.get_filing_html(ticker="AAPL", form="10-K")
parser = sp.Edgar10QParser()

with warnings.catch_warnings():
    warnings.filterwarnings("ignore", message="Invalid section type for")
    elements: list = parser.parse(html)

tree: sp.SemanticTree = sp.TreeBuilder().build(elements)

demo_output_1: str = sp.render(elements)
demo_output_2: str = sp.render(tree)

Method 2: Skip the parsing steps related to the 10Q top level section types

from sec_downloader import Downloader
import sec_parser as sp
from sec_parser.processing_steps import TopSectionManagerFor10Q, IndividualSemanticElementExtractor, TopSectionTitleCheck

dl = Downloader("MyCompanyName", "[email protected]")
html = dl.get_filing_html(ticker="AAPL", form="10-K")

def without_10q_related_steps():
    all_steps = sp.Edgar10QParser().get_default_steps()
    
    # Change 1: Remove the TopSectionManagerFor10Q
    steps_without_top_section_manager = [step for step in all_steps if not isinstance(step, TopSectionManagerFor10Q)]
    
    # Change 2: Replace the IndividualSemanticElementExtractor with a new one that has the top section checks removed
    def get_checks_without_top_section_title_check():
        all_checks = sp.Edgar10QParser().get_default_single_element_checks()
        return [check for check in all_checks if not isinstance(check, TopSectionTitleCheck)]
    return [
        IndividualSemanticElementExtractor(get_checks=get_checks_without_top_section_title_check) 
        if isinstance(step, IndividualSemanticElementExtractor) 
        else step
        for step in steps_without_top_section_manager
    ]

parser = sp.Edgar10QParser(get_steps=without_10q_related_steps)
elements: list = parser.parse(html)
tree: sp.SemanticTree = sp.TreeBuilder().build(elements)

demo_output_1: str = sp.render(elements)
demo_output_2: str = sp.render(tree)

Feedback

Let us know if it helped or if you have any further questions!

Thanks,
Elijas


Related: #80
Related: #81

from sec-parser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.