-
Notifications
You must be signed in to change notification settings - Fork 17
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
Expected encoding of libxlswriter #31
Comments
See https://libxlsxwriter.github.io/worksheet_8h.html:
|
See #30 (which was closed, perhaps in favor of this which addresses the same issue) This file produces an unopenable xlsx file:
This is presumably due to the encoding which should appear as "43 cm³". A call to System Info
|
First, you are using a really old version of R. Please update. I think your problem appears not in writexl, but earlier on when you read the text file. Please Try the following code to read your text as Windows encoded: library(readr)
library(writexl)
dn <- read_csv("bad.txt", locale = locale(encoding = 'ISO-8859-1'))
print(dn)
writexl::write_xlsx(dn, "bad.xlsx") We cannot call |
I don't think that it is *really* old.
The problem is definitely incorrectly encoded text. The data was read in
correctly. And the workflow is not unusual. Adobe Forms > Export to
Spreadsheet > read_csv() or read_excel(). I understand that it is probably
not something that write_xlsx() should maybe handle but the limitation
should be documented as Excel used in the workflow does not produce a
similar error.
Chris
…On Wed, Jan 9, 2019 at 2:36 AM Jeroen Ooms ***@***.***> wrote:
First, you are using a really old version of R. Please update
<https://cran.r-project.org/bin/windows/base/>.
I think your problem appears not in writexl, but earlier on when you read
the text file. Please print() the data before writing, so that we can see
if the encoding was correct before exporting to xlsx.
Try the following code to read your text as Windows encoded:
library(readr)
library(writexl)dn <- read_csv("bad.txt", locale = locale(encoding = 'ISO-8859-1'))
print(dn)writexl::write_xlsx(dn, "bad.xlsx")
We cannot call iconv unconditionally as you suggest, because this will
actually corrupt correctly encoding text. You just need to make sure you
read in your data properly.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#31 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AC5xa6SPqznbODgt5hp-VsrzLhDi85SJks5vBcYZgaJpZM4Z2hpK>
.
|
There really isn't any limitation on the The problem with plain text file (including csv) is that you don't know which encoding they are in. It looks like adobe exports it as 'ISO-8859-1' on Windows, but |
Lookup what encoding libxlsxwriter expects for strings.
The text was updated successfully, but these errors were encountered: