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

Comments

@jllipatz
Copy link

commented Jun 19, 2019

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

This comment has been minimized.

Copy link
Contributor

commented Jun 19, 2019

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

This comment has been minimized.

Copy link
Contributor

commented Jun 19, 2019

related to #132 .

@jllipatz

This comment has been minimized.

Copy link
Author

commented Jun 21, 2019

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

This comment has been minimized.

Copy link
Contributor

commented Sep 23, 2019

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

@leeper

This comment has been minimized.

Copy link
Owner

commented Oct 3, 2019

@bokov I think this is now fixed, right?

@bokov

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Owner

commented Oct 5, 2019

Super!

@leeper leeper closed this Oct 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.