Skip to content

col_names is rejected with ODS files #206

Closed
@jllipatz

Description

@jllipatz

When trying to read an ODS file with no header line containing column names, I get the following message :
formal argument "col_names" matched by multiple actual arguments

Example:

library(readODS)
write_ods(mtcars,"mtcars.ods")
adding: content.xml (deflated 96%)
adding: META-INF/ (stored 0%)
adding: META-INF/manifest.xml (deflated 61%)
adding: meta.xml (deflated 51%)
adding: mimetype (deflated 4%)
adding: styles.xml (deflated 70%)
import("mtcars.ods",col_names=FALSE)
Error in readODS::read_ods(path = file, sheet = which, col_names = header, :
formal argument "col_names" matched by multiple actual arguments
read_ods("mtcars.ods",col_names=FALSE)
Parsed with column specification:
....

Activity

chainsawriot

chainsawriot commented on Jun 19, 2019

@chainsawriot
Collaborator

There is an undocumented header argument for rio::.import.rio_ods, it will convert automatically into col_names. So, at the moment, you can try: import('mtcars.ods', header = FALSE)

Unfortunately, this argument is not documented. Probably because in the early days of rio, there was a need to unify all header / col_names arguments into header. It makes sense to remove that now.

@leeper

chainsawriot

chainsawriot commented on Jun 19, 2019

@chainsawriot
Collaborator

related to #132 .

jllipatz

jllipatz commented on Jun 21, 2019

@jllipatz
Author

Is there a chance that the 'header' argument will disappear in some future? If so, the solution is not better than using read_ods instead of import!

bokov

bokov commented on Sep 23, 2019

@bokov
Contributor

#225 might fix this by mapping it same way that the which argument is mapped.

leeper

leeper commented on Oct 3, 2019

@leeper
Contributor

@bokov I think this is now fixed, right?

bokov

bokov commented on Oct 4, 2019

@bokov
Contributor

Yes! This is fixed (in addition, confirming that the write_ods() used in the original reprex gives the same outcome as export()).

> export(mtcars,'mtcars1.ods')
  adding: content.xml (deflated 96%)
  adding: META-INF/ (stored 0%)
  adding: META-INF/manifest.xml (deflated 61%)
  adding: meta.xml (deflated 51%)
  adding: mimetype (deflated 4%)
  adding: styles.xml (deflated 70%)
> write_ods(mtcars,'mtcars2.ods')
  adding: content.xml (deflated 96%)
  adding: META-INF/ (stored 0%)
  adding: META-INF/manifest.xml (deflated 61%)
  adding: meta.xml (deflated 51%)
  adding: mimetype (deflated 4%)
  adding: styles.xml (deflated 70%)
> mt1 <- import('mtcars1.ods',col_names=F)
Parsed with column specification:
cols(
  A = col_character(),
  B = col_character(),
  C = col_character(),
  D = col_character(),
  E = col_character(),
  F = col_character(),
  G = col_character(),
  H = col_character(),
  I = col_character(),
  J = col_character(),
  K = col_character()
)
> mt2 <- import('mtcars2.ods',col_names=F)
Parsed with column specification:
cols(
  A = col_character(),
  B = col_character(),
  C = col_character(),
  D = col_character(),
  E = col_character(),
  F = col_character(),
  G = col_character(),
  H = col_character(),
  I = col_character(),
  J = col_character(),
  K = col_character()
)
> identical(mt1,mt2)
[1] TRUE
leeper

leeper commented on Oct 5, 2019

@leeper
Contributor

Super!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

      Participants

      @chainsawriot@leeper@bokov@jllipatz

      Issue actions

        col_names is rejected with ODS files · Issue #206 · gesistsa/rio