Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: "invalid input found on input connection" in pull_gemm() #165

Closed
iantaylor-NOAA opened this issue Dec 19, 2024 · 2 comments
Closed
Labels

Comments

@iantaylor-NOAA
Copy link
Contributor

While trying to run nwfscSurvey::pull_gemm(), I'm getting an error from this section of code:

# Pull all gemm data
gemm <- utils::read.csv(
url("https://www.webapps.nwfsc.noaa.gov/data/api/v1/source/observer.gemm_fact/selection.csv"),
encoding = "UTF-8-BOM"
) %>%

> widow_data <- nwfscSurvey::pull_gemm(common_name = "widow rockfish")
i Output will not be saved in dir because dir = NULL.
Error in read.table(file = file, header = header, sep = sep, quote = quote,  : 
  no lines available in input
In addition: Warning message:
In read.table(file = file, header = header, sep = sep, quote = quote,  :
  invalid input found on input connection 'https://www.webapps.nwfsc.noaa.gov/data/api/v1/source/observer.gemm_fact/selection.csv'

Pasting the URL into my browser causes the CSV to be downloaded which allowed me to explore what's going on locally.
I tried removing almost all the contents of the file and it still had problems.

When reading bad.csv via read.csv("bad.csv") I get the same error.
When reading good.csv, which looks identical, I get no error in spite of the fact that good.csv is just the contents of bad.csv copied to a new file in my vscode editor.

The entire contents of both good.csv and bad.csv (as far as I can tell) are

"cv","grouping" 
"","Yellowtail rockfish" 

That makes me think that there must be some hidden characters that vscode is stripping away when I copy and paste. Remarkably, when I download bad.csv from this github issue (in preview) I still get an error when trying to read it.

@Curt-Whitmire-NOAA and @chantelwetzel-noaa, do you know of any changes to the data warehouse that would have caused this problem?

@iantaylor-NOAA
Copy link
Contributor Author

@chantelwetzel-noaa helped me discover that this problem doesn't occur if I run the code outside of vscode. Indeed, I can run it in vscode on a different computer which doesn't have the radian terminal set up. So clearly just a me problem. We can reopen if it happens to somebody else. Sorry for the distraction.

@iantaylor-NOAA
Copy link
Contributor Author

Update: I was able to get the function working by first running Sys.setlocale("LC_ALL", Sys.getenv("LANG")) as suggested in this issue on the radian site: randy3k/radian#269.

I would suggest ignoring this unless it comes up for somebody else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant