Problem reading a CSV file

Dear,

I'm having trouble reading the CSV file from the link https://brasil.io/dataset/covid19/caso/?state=PB&format=csv. I tried in the following ways:

readr::read_csv("https://brasil.io/dataset/covid19/caso/?state=PB&format=csv")

#or 

read.csv("https://brasil.io/dataset/covid19/caso/?state=PB&format=csv/")

Apparently the reading is done correctly, but the return is an HTML file. How to read the table correctly?

The problem seems to be that the file requires authentication. Do you have access to it? If you have access to it, downloading it and loading it locally seems like a quick fix.

2 Likes

Dear,

I have access to the file.

In fact anyone has access, it is free from an Open Source project. The file is obtained by clicking on the link. The problem is that I need to download the file automatically, there are hundreds of others like this. When I use the download.file() command, the file downloads in an HTML format.

I cannot access the file so I can't help much more than this I am afraid. As mentioned before it requires a login, at least to me.

If the downloaded file is an HTML, my bet is that it is the login/error page due to authentication.

I agree. OP is probably logged in already. When I had to download from a secured google sheet I found that I had to set the browser in R to the one that I used to authenticate. This may get OP past the authentication step.

options(browser = "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe")
browseURL("https://docs.google.com/spreadsheets/export?format=csv&id=xxxxxxx") 
1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.