Skip to content

Inconsistent parsing failure "no trailing characters e3" #645

@cswaters

Description

@cswaters

I'm importing a raw csv file using read_csv.

  1. The raw csv file contains date column, on import it's converted to col_datetime format.
  2. I create a column seas (short for season) using the code

df <- mutate(df, seas = ifelse(month(date) < 5, year(date) - 1, year(date)))

  1. I run the code group_by(df, seas) %>% tally() to check the seasons calculated properly. The output looks good. No NA values.
seas n
1999 642
2000 648
2001 644
2002 666
2003 664
2004 664
2005 666
  1. Export the dataframe with the new seas column using write_csv.
  2. Import the new csv (the one created in the step above) and get the error.

Warning: 648 parsing failures.

row col expected actual file
1453 seas no trailing characters e3 'df_cleaned.csv'
1454 seas no trailing characters e3 'df_cleaned.csv'
1455 seas no trailing characters e3 'df_cleaned.csv'
1456 seas no trailing characters e3 'df_cleaned.csv'
1457 seas no trailing characters e3 'df_cleaned.csv'

.... .... ...................... ...... ....................
See problems(...) for more details.

  1. Even though the 2000 seas (season) calculated properly before the export (see the dataframe results in step 3), upon import something is triggering a parsing issue.

unique(nfl$seas)

    [1] 1995 1996 1997 1998 1999   NA 2001 2002 2003 2004 2005 2006 2007
    [14] 2008 2009 2010 2011 2012 2013 2014 2015 2016

filter(df, is.na(seas)) %>% select(date, seas) produces

A tibble: 648 × 2

date seas
2000-07-29 NA
2000-07-29 NA
2000-07-30 NA
2000-07-30 NA
  1. read.csv works with no issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions