If you specify header=TRUE
, then, as per ?read.fwf
, you must ensure that the column names are separated by sep
. The default is for names to be separated by \t
(the tab character) and this must not be true for your data.
The following works just fine:
w <- c(11, 10, 57, 16, 3, 5, 8)
read.fwf(widths=w, header=TRUE, sep='|',
file=textConnection('LastName |Date |email |CreditCardNum |Age|Zip |Amount
Paul 21/02/14 Aliquam.fringilla@dolordapibus.co.uk 4241033422900360 6738851$14.39
Bullock 2/7/2014adipiscing.fringilla@lectusjusto.org 5178789953524240 3336538$498.31
Mcmahon 11/5/2013lobortis.ultrices@lacus.org 5389589582467450 7734302$92.44
Walters 25/09/13 consectetuer.cursus.et@sitamet.org 5157094536097720 7794007$206.60
Franco 17/06/13 et@disparturientmontes.ca 345477952996264 2415873$89.12'))