Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected behavior in parsing TXT file #516

Closed
stebif68 opened this issue Sep 9, 2016 · 1 comment
Closed

Unexpected behavior in parsing TXT file #516

stebif68 opened this issue Sep 9, 2016 · 1 comment

Comments

@stebif68
Copy link

stebif68 commented Sep 9, 2016

I am reading data using readr. Data is txt file where each column is separate by one (or more) columns of space.
Data has 1000 rows. If I read 996 rows, the first col is an integer. If I read 997 rows, the same first col is character. I guess there is some "special" character but I cannot figure out what's going on

DAT44M100.txt

DatiMorf44xxx <- read_table(file.path(dir,'DAT44M.txt'),col_names = c('id','OpDim',
'YearSeason',
'HerdYear',
'age','age2',
'v1','v2',
'v3','v4',
'v5','v6',
'v7','v8'),
n_max=996)
cols(
id = col_integer(),
OpDim = col_integer(),
YearSeason = col_integer(),
HerdYear = col_integer(),
age = col_integer(),
age2 = col_integer(),
v1 = col_integer(),
v2 = col_integer(),
v3 = col_integer(),
v4 = col_integer(),
v5 = col_integer(),
v6 = col_integer(),
v7 = col_integer(),
v8 = col_integer()
)

DatiMorf44xxx <- read_table(file.path(dir,'DAT44M.txt'),col_names = c('id','OpDim',
'YearSeason',
'HerdYear',
'age','age2',
'v1','v2',
'v3','v4',
'v5','v6',
'v7','v8'),
n_max=997)

cols(
id = col_character(),
OpDim = col_integer(),
YearSeason = col_integer(),
HerdYear = col_integer(),
age = col_integer(),
age2 = col_integer(),
v1 = col_integer(),
v2 = col_integer(),
v3 = col_integer(),
v4 = col_integer(),
v5 = col_integer(),
v6 = col_integer(),
v7 = col_integer(),
v8 = col_integer()
)

@hadley
Copy link
Member

hadley commented Dec 22, 2016

Duplicate of #518

@hadley hadley closed this as completed Dec 22, 2016
@lock lock bot locked and limited conversation to collaborators Sep 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants