Skip to content

CLI utility to convert SPSS .sav files to long or flat format csv files.

License

Notifications You must be signed in to change notification settings

erbarratt/savtocsv

Repository files navigation

savtocsv

SPSS .sav to short or long format csv file

PLEASE USE NEW REPOSITORY SAV2CSV - THIS ONE IS NO LONGER MAINTAINED https://github.com/erbarratt/sav2csv

Compile using CMake / make

Installation has so far been tested on Debian (+Raspbian, +Ubuntu 20.04), Redhat (+CentOs 7) and macOS Catalina (10.15.7).

Only requires C Standard Library.

# sudo curl -OL https://github.com/erbarratt/savtocsv/archive/refs/heads/main.tar.gz

or

# sudo wget https://github.com/erbarratt/savtocsv/archive/refs/heads/main.tar.gz

Verify installation using the version option:

# ./savtocsv -v

Should output similar to:

savtocsv version 1.9.3 2021-04-02

Usage

To call the program in it's current directory, use:

# sudo ./savtocsv [options] [arguments]

sudo is needed for being able to write files correctly.

Help

The help option is exclusive - the help output will only run if -h is the sole option passed. Help lists all available options.

# ./savtocsv -h

Version

The version option is exclusive - the version output will only run if -v is the sole option passed.

# ./savtocsv -v

Input file*

Use -f to define the input .sav file.

*This option is required

# sudo ./savtocsv -f filename.sav

Output file prefix

Use -o to define the prefix for any output csv's. The program will append x.csv, where x is the number of the current csv file being written to, determined by the line limit option. Defaults to "out" (therefor out1.csv, out2.csv...).

# sudo ./savtocsv  -f filename.sav -o prefix

CSV Line limit

Use -l to define how many rows should make up each output csv. Defaults to 1000000 (1 million). If output rows less, then only one file is generated. Program will check to see if this is a valid integer greater than 0.

# sudo ./savtocsv  -f filename.sav -l 500000

Silent mode

Use -s to disable all output to stdout.

# sudo ./savtocsv  -f filename.sav -s

Debug mode

Use -d to enable Debug mode, which will output all information read by the program from the .sav file. Debug mode will only output if not in silent mode.

# sudo ./savtocsv  -f filename.sav -d

Flat csv

Use -F to output csv files as flat table style. Default is long format csv (many to many).

# sudo ./savtocsv  -f filename.sav -F

Row index

Use -R to output the row index as the first field in each line of the csv.

# sudo ./savtocsv  -f filename.sav -R

Full example

Set filename, output prefix and line limit, in silent mode, as a flat style csv including row indexes.

# sudo ./savtocsv  -f filename.sav -o prefix -l 5000000 -sFR

About

CLI utility to convert SPSS .sav files to long or flat format csv files.

Topics

Resources

License

Stars

Watchers

Forks