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

Use old-style SPSS compression by default for .sav (SPSS) files, sinc… #544

Merged
merged 1 commit into from
Apr 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
* Updated to ReadStat 1.1.5. Most importantly this includes support for
SAS binary compression.

* `write_sav(..., compress=FALSE)` now uses SPSS Bytecode compression instead
of the rarely-used uncompressed mode. `compress=TRUE` continues to use the new
(and not universally supported, but more compact) ZLIB format. (@oliverbock, #544)

# haven 2.3.1

* Add missing methods so `median()`, `quantile()` and `summary()` work
Expand Down
2 changes: 1 addition & 1 deletion R/haven.R
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ read_por <- function(file, user_na = FALSE, col_select = NULL, skip = 0, n_max =
#' @export
#' @rdname read_spss
#' @param compress If `TRUE`, will compress the file, resulting in a `.zsav`
#' file.
#' file. Otherwise the `.sav` file will be bytecode compressed.
write_sav <- function(data, path, compress = FALSE) {
validate_sav(data)
write_sav_(data, normalizePath(path, mustWork = FALSE), compress = compress)
Expand Down
2 changes: 1 addition & 1 deletion man/read_spss.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/DfWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,8 @@ void write_sav_(cpp11::list data, cpp11::strings path, bool compress) {
Writer writer(HAVEN_SAV, data, path);
if (compress)
writer.setCompression(READSTAT_COMPRESS_BINARY);
else
writer.setCompression(READSTAT_COMPRESS_ROWS);
writer.write();
}

Expand Down