0

I'm trying to download financial statements in R using a package at: Financial statements in R

I'm trying to modify the example in their read me for other companies. I have tried to download the last two Tesla Q's.

The code I modified so far is:

 xbrl_url2017Q3 <- "https://www.sec.gov/Archives/edgar/data/1318605/000156459018026353/tsla-20180930.xml"
 xbrl_url2017Q2 <- "https://www.sec.gov/Archives/edgar/data/1318605/000156459018019254/tsla-20180630.xml"
 old_o <- options(stringsAsFactors = FALSE)
 xbrl_data_tsla2017Q3 <- xbrlDoAll(xbrl_url2017Q3)

Error from the line above is:

Error in fileFromCache(file) : Error in download.file(file, cached.file, quiet = !verbose) : cannot open URL 'https://www.sec.gov/Archives/edgar/data/1318605/000156459018026353/https://xbrl.sec.gov/dei/2018/dei-2018-01-31.xsd'

In addition: Warning message: In download.file(file, cached.file, quiet = !verbose) : cannot open URL 'https://www.sec.gov/Archives/edgar/data/1318605/000156459018026353/https://xbrl.sec.gov/dei/2018/dei-2018-01-31.xsd': HTTP status was '403 Forbidden'

 xbrl_data_tsla2017Q2 <- xbrlDoAll(xbrl_url2017Q2)
 options(old_o)

 tsla2017Q3 <- xbrl_get_statements(xbrl_data_tsla2017Q3)
 tsla2017Q2 <- xbrl_get_statements(xbrl_data_tsla2017Q2 )
 tsla2017Q2

balance_sheet2017Q2 <- tsla2017Q2$StatementOfFinancialPositionClassified
balance_sheet2017Q3<- tsla2017Q3$StatementOfFinancialPositionClassified
income2017Q2 <- tsla2017Q2$StatementOfIncome
income2017Q3 <- tsla2017Q3$StatementOfIncome
balance_sheet2017Q3

Returns "NULL"

See the 10-Q at tesla's SEC fillings.

The last 10-Q.

Any recommendations on how I can go about this?

I'm looking to download the financial data to play around it with and would like it in tidy formate.

3
  • I have tried to download the last two Tesla Q's. ... And what happened? Please describe the problem. Errors? Undesired results?
    – Parfait
    Commented Jan 13, 2019 at 3:01
  • in your xbrl_get_statements you are referencing aapl not tsla, xbrl_data_aapl2013; this object is not defined and is a leftover of your copy and pasting from the package vignette. You need xbrl_data_tsla2017Q3 in this field. Fix this first and see if you still have an error.
    – phiver
    Commented Jan 13, 2019 at 9:25
  • I updated my code to show where I get the errors. Maybe It's the link I use to the file. I'm also open to other packages if anyone else knows. Currently playing around in python to see if I can solve that issue there. Commented Jan 13, 2019 at 20:16

1 Answer 1

2

This is a common problem with the XBRL package where not all XML schemas are downloaded in the cache for some SEC filings. Download the missing schema in your cache folder and retry the xbrlDoAll call - it should work this time.

4
  • 1
    Thank you, I didn’t understand about schemas, and this solved my problem. It would have helped even more if you explained that I had to go one by one on the sec website, download the missing xsd file, remove the .htm subscript and put in the cache. If there is an easier way to update all schemes, that would have really been amazing, but I didn’t figure that out. Gave you +1 Commented Feb 9, 2020 at 12:12
  • Hi David, could you please explain how did you fix this issue? How did you download the .htm? And in which cache folder to save the .xsd?
    – Vitomir
    Commented Sep 21, 2020 at 17:25
  • @DavidLucey, I'd also be interested to hear more about your process, esp. relating to removing the .htm subscript. I'm not seeing that in the contents of the .xsd file. I've been saving the relevant .xsd files R tells me are missing in the cache folder in my working directory, but my cache folder is deleted after using a finreportr function and I need to download the missing .xsd files again.
    – LauraDR
    Commented Oct 13, 2020 at 20:55
  • 1
    I wrote this post redwallanalytics.com/2020/02/18/… and there is a lot on this subject in the comments Commented Oct 13, 2020 at 21:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.