You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
check column name encoding attribute and column contents encoding attribute
print(stringi::stri_enc_mark(colnames(d2)))
#> [1] "ASCII" "native" "UTF-8" "UTF-8" # second column created by mutate step
print(stringi::stri_enc_mark(d2$性別))
#> [1] "UTF-8" "UTF-8" "UTF-8" "UTF-8" "UTF-8" "UTF-8" "UTF-8" "UTF-8"...# third column converted by pivot_longer from column name
print(stringi::stri_enc_mark(d2$実施回))
#> [1] "native" "native" "native" "native" "native" "native" "native" "native"...
Second column ("性別") contents has "UTF-8" encoding attribute, because they created by mutate step. Other-hands, third column ("実施回") contents has "native" encoding attribute, because converted from column name that has "native" encoding attribute.
So, dataframe "d2" has column with "UTF-8" encoding attribute and column with "native" encoding attribute. When I try to write this "d2" dataframe to CSV file by "write_csv", unexpected CSV files is generate.
The problem is that at first glance it appears to be generated correctly. "write_csv" show no error or warning messages.
Is it possible to perform the write_csv correctly without converting it to UTF-8 by hand, or detecting errors?
Or Is this problem about dplyr (mutate) or tidyr (pivot_longer)?
The text was updated successfully, but these errors were encountered:
Could you please rework your reproducible example to use the reprex package ? That makes it easier to see both the input and the output, formatted in such a way that I can easily re-run in a local session.
if dataframe has columns with mixed encoding attribute, write_csv gerenates unexpected CSV file.
Second column ("性別") contents has "UTF-8" encoding attribute, because they created by mutate step. Other-hands, third column ("実施回") contents has "native" encoding attribute, because converted from column name that has "native" encoding attribute.
So, dataframe "d2" has column with "UTF-8" encoding attribute and column with "native" encoding attribute. When I try to write this "d2" dataframe to CSV file by "write_csv", unexpected CSV files is generate.
I expect all files is same, but these file different from each other.
All files is same.
The problem is that at first glance it appears to be generated correctly. "write_csv" show no error or warning messages.
Is it possible to perform the write_csv correctly without converting it to UTF-8 by hand, or detecting errors?
Or Is this problem about dplyr (mutate) or tidyr (pivot_longer)?
The text was updated successfully, but these errors were encountered: