---
name: "extract_metadata"
section: "1"
platform: "linux"
package: "readstat"
version: "1.1.9-2"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/extract_metadata"
---

# extract\_metadata(1)

read column metadata from SPSS and Stata binary files, and format it as JSON

## NAME

extract\_metadata - read column metadata from SPSS and Stata binary files, and format it as JSON

## SYNOPSIS

**extract\_metadata** *input-file* *output-file*

## DESCRIPTION

**extract\_metadata** reads column metadata from existing binary data files, so that **readstat** can produce new, column-compatible binary files from CSV input files. Both programs use JSON as a metadata interchange format.

The *input-file* should be a file with one of the following extensions:

- *dta*

  Stata binary file, version 104 or newer

- *sav*

  SPSS uncompressed binary file

- *zsav*

  SPSS compressed binary file

In all cases, *output-file* should end in .json.

## EXAMPLE

Suppose you have a Stata file with last year's survey data, and want to produce a compatible Stata file containing this year's survey data. First, extract the metadata:

```
extract_metadata last-year.dta survey-metadata.json
```

Now apply it to this year's data, which is stored in a CSV file:

```
readstat this-year.csv metadata.json this-year.dta
```

The first line of the CSV file should contain column names which match the column names in last-year.dta. If everything went well, your new binary data set is now stored in this-year.dta.

## OPTIONS

None.

## AUTHOR

Copyright (C) 2012-2019 Evan Miller, and others where indicated.
