fwf2csv: Creates a CSV Representation of Data Accoding to Stacks of...

Description Usage Arguments Value Note Author(s) References Examples

View source: R/fwf2csv.R

Description

Uses awk to convert a fixed-width file to a CSV based on stacks of whitespace.

Usage

1
fwf2csv(infile, toDF = FALSE, ...)

Arguments

infile

The input file. Can also be "clipboard" to read directly from the clipboard.

toDF

Logical. Should the file be read in while we are at it? Defaults to FALSE.

...

Other arguments to be passed to read.table.

Value

A vector or a data.frame, depending on the value in toDF.

Note

Only tested on Linux.

Author(s)

Ananda Mahto and Ed Morton.

References

http://stackoverflow.com/q/30868600/1270695

Examples

1
2
3
4
5
6
7
myfile <- tempfile(fileext = ".txt")
Lines <- c("aaa  b b ccc      345", "ddd  fgt f u      3456", "e r  der der      5 674")
cat(Lines, sep = "\n")
cat(Lines, sep = "\n", file = myfile)
fwf2csv(myfile)
fwf2csv(myfile, TRUE, header = FALSE)
 

mrdwab/SOfun documentation built on June 20, 2020, 6:15 p.m.