https://github.com/finnishcancerregistry/fwf
Read and write fixed-width format data.
https://github.com/finnishcancerregistry/fwf
data-export data-import data-processing epidemiology file-format fixed-width-format fwf io r-package tabular-data text-data
Last synced: about 1 month ago
JSON representation
Read and write fixed-width format data.
- Host: GitHub
- URL: https://github.com/finnishcancerregistry/fwf
- Owner: FinnishCancerRegistry
- License: other
- Created: 2023-03-27T18:12:42.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2025-03-06T11:08:20.000Z (about 2 months ago)
- Last Synced: 2025-03-06T12:22:50.720Z (about 2 months ago)
- Topics: data-export, data-import, data-processing, epidemiology, file-format, fixed-width-format, fwf, io, r-package, tabular-data, text-data
- Language: R
- Homepage:
- Size: 17.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: NEWS.md
- License: LICENSE
Awesome Lists containing this project
README
# Package `fwf`
`fwf` is a tiny package to read and write fixed width format tables.
[](https://github.com/FinnishCancerRegistry/fwf/actions/workflows/R-CMD-check.yaml)
# Example
```r
# Remember, data types other than character, integer, and double may not
# be properly handled (because meta-information about datatype is lost when
# writing into a text file). See ?data.table::fread for more control.
# over reading behaviour.
exp <- data.frame(
col1 = c("abcdefghijklmn", "abc"),
col2 = c(1e6L, 1L),
col3 = as.Date(c("2000-01-01", "2001-01-01"))
)
tf <- tempfile(pattern = "fwf_file_", fileext = ".txt")
fwf::fwf_write(exp, tf)
obs <- fwf::fwf_read(
path = tf,
fread_arg_list = list(colClasses = c(col3 = "Date"))
)
stopifnot(
all.equal(exp, obs, check.attributes = FALSE),
identical(lapply(exp, class), lapply(obs, class))
)
```# Installation
```r
devtools::install_github("FinnishCancerRegistry/fwf")
````