Skip to content

numeric columns read as dates #589

Description

@benzipperer

Thanks for the excellent package!

With the spreadsheet TRACT_ZIP_092019.xlsx, readxl guesses columns 3-6 are dates, but they should be numeric:

read_excel("TRACT_ZIP_092019.xlsx")

# A tibble: 170,193 x 6                                                        
   tract zip   res_ratio           bus_ratio           oth_ratio          
   <chr> <chr> <dttm>              <dttm>              <dttm>             
 1 010036067 1900-01-01 00:00:00 1900-01-01 00:00:00 1900-01-01 00:00:00
 2 010036067 1900-01-01 00:00:00 1900-01-01 00:00:00 1900-01-01 00:00:00
 3 010036067 1900-01-01 00:00:00 1900-01-01 00:00:00 1900-01-01 00:00:00
 4 010036067 1899-12-31 00:36:16 1899-12-31 13:58:28 1899-12-31 06:00:00
 5 010036066 1899-12-31 23:23:43 1899-12-31 10:01:31 1899-12-31 18:00:00
 6 010036068 1899-12-31 04:44:07 1899-12-31 10:58:22 1899-12-31 00:10:21
 7 010036067 1899-12-31 00:01:17 1899-12-31 00:27:00 1899-12-31 00:00:00
 8 010036066 1899-12-31 19:14:34 1899-12-31 12:34:36 1899-12-31 23:49:38
 9 010036067 1900-01-01 00:00:00 1900-01-01 00:00:00 1900-01-01 00:00:00
10 010036067 1900-01-01 00:00:00 1900-01-01 00:00:00 1900-01-01 00:00:00
# … with 170,183 more rows, and 1 more variable: tot_ratio <dttm>

The following command produces the desired output

read_excel("TRACT_ZIP_092019.xlsx", col_types = c("text", "text", "numeric", "numeric", "numeric", "numeric"))

By the way, why does the latter take longer to execute even though I'm specifying the column types?

Spreadsheet source: https://www.huduser.gov/portal/datasets/usps_crosswalk.html#data

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions