fw_use
Load a named dataset and check its integrity
fw_use loads a dataset by name. A name is resolved in this order:
- A file path, such as
inputs/raw/survey.csv. A relative path is tried from the current folder, then from the project root. - An entry in the project's data catalog, such as
inputs.raw.survey. - Dot notation: the longest leading part that names a project folder picks the folder, and the rest names the file.
inputs.final.analysisis$fw_inputs_final/analysis.dta.
The extension picks the reader: .dta uses use, .csv and .tsv use import delimited, and .xlsx and .xls use import excel, firstrow.
Usage
fw_use name [, clear check(strict|warn|off|accept) options(string)]
Options
| Name | Default | Description |
|---|---|---|
| name required |
A file path, a catalog name, or a dot name. |
|
| clear |
Replaces the data in memory. |
|
| check(strict|warn|off|accept) | strict |
Sets the integrity check. |
| options(string) |
Options passed to |
Value
r(name): the dataset namer(path): the filer(type):dta,csv,tsv,xlsx, orxlsr(sha256): the file checksum, when availabler(datasignature): the data signaturer(locked): 1 when the dataset is lockedr(accepted): 1 whencheck(accept)recorded the dataset again
Details
Before loading, fw_use computes the file's SHA-256 checksum and compares it with the record from the last fw_save or fw_use. After loading, it compares Stata's datasignature. A dataset that changed stops with error 459 when it is locked, and loads with a warning when it is unlocked. To accept a change to a locked dataset, load it with check(accept). It records the new checksum and data signature and keeps the lock. The file is not rewritten.
The checksum covers the whole file, as in R and Python. A .dta file holds the time it was saved, so saving the same data again with plain save changes the checksum, and a locked dataset then stops with error 459. Save with fw_save, which records the new file, or accept the change with check(accept).
The first read of a name records it. Reads of unlocked datasets update the record, as in R and Python. Records live in .framework/stata-integrity.tsv. Plain file paths are not recorded.
SHA-256 comes from sha256sum or shasum on Linux and macOS and from PowerShell on Windows. Without one, only datasignature is checked. It covers values and variable names. It does not cover labels or notes.
Examples
Not run
fw_use inputs.raw.survey, clear
A CSV file by path Not run
fw_use "inputs/raw/visits.csv", clear options(varnames(1))
Accept a change to a locked dataset Not run
fw_use inputs.raw.survey, clear check(accept)