piquette / edgr

A set of tools for dealing with SEC EDGAR corporate filings
https://piquette.io/projects/edgr
Apache License 2.0
23 stars 7 forks source link

The function GetPublicCompanies always throws the error index out of range [1] with length 1 #3

Open ParthaI opened 1 year ago

ParthaI commented 1 year ago

Dear Team,

I was trying to list of all US public companies registered with the US Securities and Exchange Commission. We aimed to achieve this by using the API GetPublicCompanies API. Regrettably, this approach has consistently resulted in errors during our attempts.

Furthermore, I have made an attempt to troubleshoot the code locally by implementing certain modifications. Unfortunately, these adjustments did not yield the desired successful execution.

import (
    "context"
    "encoding/csv"
    "fmt"
    "net/http"

    "github.com/piquette/edgr/core"
)

func main() {
      headers :=  map[string]string{"User-Agent": "Steampipe/v0.x"}
    req, err := http.NewRequest("GET", "https://api.iextrading.com/1.0/ref-data/symbols?format=csv", nil)
    if err != nil {
        return []core.Company{}, err
    }

    for k, v := range headers {
        req.Header.Set(k, v)
    }

    resp, err := http.DefaultClient.Do(req)
    if err != nil {
        return []core.Company{}, err
    }
    defer resp.Body.Close()

    r := csv.NewReader(resp.Body)
    r.FieldsPerRecord = -1
    table, _ := r.ReadAll()
    result := []core.Company{}
    for _, row := range table {
        if len(row) < 2 {
            fmt.Sprint("ROW =====>>>>>", row)
            continue
        }
        sym := row[0]
        nme := row[1]
        if len(sym) > 5 || nme == "" {
            continue
        }
        result = append(result, core.Company{
            Symbol: sym,
            Name:   nme,
        })
    }
}

Could you please check it out and let us know I am doing anything wrong or it is a bug from SDK side?

Thanks!

ParthaI commented 10 months ago

Dear team, Is there any update on this issue?