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

col_names is rejected with ODS files #206

Closed
jllipatz opened this issue Jun 19, 2019 · 7 comments
Closed

col_names is rejected with ODS files #206

jllipatz opened this issue Jun 19, 2019 · 7 comments

Comments

@jllipatz
Copy link

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:
....

@chainsawriot
Copy link
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
Copy link
Collaborator

related to #132 .

@jllipatz
Copy link
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
Copy link
Contributor

bokov commented Sep 23, 2019

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

@leeper
Copy link
Contributor

leeper commented Oct 3, 2019

@bokov I think this is now fixed, right?

@bokov
Copy link
Contributor

bokov commented Oct 4, 2019

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
Copy link
Contributor

leeper commented Oct 5, 2019

Super!

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

No branches or pull requests

4 participants