0
votes

I am trying to pull data from Sec.gov's EDGAR system for specific financial statements of specific filings for specific companies.

The first problem I am having in doing this is trying to figure out how to generally pull data from, for example, this link into a table in google sheets: https://www.sec.gov/cgi-bin/viewer?action=view&cik=320193&accession_number=0000320193-20-000096&xbrl_type=v#

The second problem I am having is trying to pull such data, but from specific financial statements (like the statements of cash flows) in the "financial statements" section, as the link above only brings me to the cover page of the filing, and each separate tab does not have separate links.

I am new at scripting within google sheets and am struggling to even find how to start at such a script that can do the above. This script I found on reddit (https://www.reddit.com/r/googlesheets/comments/bbousq/help_with_a_script_that_fetches_data_from_secgov/) is the closest script I have found online for what I am trying to do; however, I am unable to make it work and I am unsure how to do so:

function secData(company, tablenum) {if (!company)

company = 'TROV';

var url = "https://www.sec.gov/cgi-bin/browse-edgar?CIK=" + company + "&owner=exclude&action=getcompany";

var result = UrlFetchApp.fetch(url).getContentText();

var reg = /<a href="\/cgi-bin\/viewer.+?cik=(\d+).+accession_number=([\d|-]+)/.exec(result);

var cik = reg[1];

var accession = reg[2];

return 'https://www.sec.gov/Archives/edgar/data/' + cik + '/' + accession.replace(/-/g, '') + '/R'+tablenum+'.htm';

}

Which uses this formula in the sheet itself:

=IF(NOT(ISBLANK(G1)), importhtml(secData(G1,4),"table",1), "")

Where:

company = company name/ticker

tablenum = number of financial statement table (3 might = balance sheet)

Overall, I am wondering how to pull sec.gov interactive EDGAR data into google sheets and am hoping someone can help me do so?

1

1 Answers

0
votes

You have an Excel document link on every page. You download that and convert it to Sheets, it's fairly easy. Here's a snippet to get you started.