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

read_sas fails when catalog_file is specified #271

Closed
rogerjdeangelis opened this Issue Jan 31, 2017 · 8 comments

Comments

Projects
None yet
3 participants
@rogerjdeangelis
Copy link

rogerjdeangelis commented Jan 31, 2017

library(haven)
zip_path <- tempfile()
download.file("https://dl.dropboxusercontent.com/u/15716238/class.zip", zip_path)
rdata_path <- unzip(zipfile=zip_path, files = "class.sas7bdat", exdir=tempdir())
zip_path1 <- tempfile()
download.file("https://dl.dropboxusercontent.com/u/15716238/simple64bit.zip", zip_path1)
rdata_path1 <- unzip(zipfile=zip_path1, files = "simple64bit.sas7bcat", exdir=tempdir())
sas <- read_sas(rdata_path,catalog_file= rdata_path1)

I am a R newbe sorry about tempfile issue.

Log
Error in df_parse_sas_file(spec_data, spec_cat, encoding = encoding) :
Failed to parse C:/Users/beast/AppData/Local/Temp/RtmpIzZteT/simple64bit.sas7bcat: Unable to read from file.
Calls: read_sas -> df_parse_sas_file -> .Call
Execution halted

@evanmiller

This comment has been minimized.

Copy link
Contributor

evanmiller commented Feb 1, 2017

@rogerjdeangelis

This comment has been minimized.

Copy link

rogerjdeangelis commented Feb 1, 2017

@rogerjdeangelis

This comment has been minimized.

Copy link

rogerjdeangelis commented Feb 9, 2017

Hi Evan

Thanks for the update!!

I tried to download the fix but it looks like R would not upgrade the previous package. So I could not get it to work

devtools::install_github("tidyverse/haven")
Skipping install of 'haven' from a github remote, the SHA1 (330c873) has not ch
anged since last install.
Use force = TRUE to force installation

I still get this error wheb running the previous accepted R script?

Error in df_parse_sas_file(spec_data, spec_cat, encoding = encoding, cols_only = cols_only) :
Failed to parse C:/Users/beast/AppData/Local/Temp/RtmpGev7R8/simple64bit.sas7bcat: Unable to read from file.
Calls: read_sas -> df_parse_sas_file -> .Call
Execution halted

@hadley hadley closed this in 4cb0d51 Feb 13, 2017

@hadley

This comment has been minimized.

Copy link
Member

hadley commented Feb 13, 2017

@rogerjdeangelis Try now - I need to update readstat before you can try haven.

Your reprex would be simpler if you didn't zip the files.

@rogerjdeangelis

This comment has been minimized.

Copy link

rogerjdeangelis commented Feb 13, 2017

Your work is appreciated!!!

Tried to simplify the unit test

library(haven)
bdat <- tempfile()
download.file("https://dl.dropboxusercontent.com/u/15716238/class.sas7bdat", bdat)
bcat<- tempfile()
download.file("https://dl.dropboxusercontent.com/u/15716238/simple64bit.zip", bcat)
sas <- read_sas(bdat,catalog_file= bcat)

LOG

Stderr output:
trying URL 'https://dl.dropboxusercontent.com/u/15716238/class.sas7bdat'
Content type 'application/octet-stream' length 131072 bytes (128 KB)
==================================================
downloaded 128 KB

trying URL 'https://dl.dropboxusercontent.com/u/15716238/simple64bit.zip'
Content type 'application/zip' length 2097 bytes
==================================================
downloaded 2097 bytes

Error in df_parse_sas_file(spec_data, spec_cat, encoding = encoding, cols_only = cols_only) :
  Failed to parse C:/Users/beast/AppData/Local/Temp/RtmpKEhpmo/file8c5dd72fc: Invalid file, or file has unsupported features.
Calls: read_sas -> df_parse_sas_file -> .Call
Execution halted
@hadley

This comment has been minimized.

Copy link
Member

hadley commented Feb 13, 2017

That doesn't work because the file on dropbox still looks like it's zipped.

You might also try using the reprex package, because it makes creating these reprexes easier. Having separate code and "log" is suboptimal, because I have to mentally reweave them back together. Reprex does that for you.

@rogerjdeangelis

This comment has been minimized.

Copy link

rogerjdeangelis commented Feb 13, 2017

Typo in previous post

changed
https://dl.dropboxusercontent.com/u/15716238/simple64bit.zip
to
https://dl.dropboxusercontent.com/u/15716238/simple64bit.sas7bcat

As a side not 32bit and 64bit format catalogs are very different.
I suggest you wotk on 64bit first

library(haven)
bdat <- tempfile()
download.file("https://dl.dropboxusercontent.com/u/15716238/class.sas7bdat", bdat)
bcat<- tempfile()
download.file("https://dl.dropboxusercontent.com/u/15716238/simple64bit.sas7bcat", bcat)
sas <- read_sas(bdat,catalog_file= bcat)
@hadley

This comment has been minimized.

Copy link
Member

hadley commented Feb 13, 2017

That works for me. Have you installed the latest haven from github?

@lock lock bot locked and limited conversation to collaborators Jun 26, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.