读取CSV的时区错误 [英] timezone error reading csv
问题描述
谷歌搜索几个小时后,我没有找到解决此问题的方法.
基本上,当我从readr
包运行read_csv("some_file.csv")
函数时,出现以下错误:
After googling for a couple of hours I have not found a solution to this problem.
Basically when I run read_csv("some_file.csv")
function from readr
package I get the following error:
错误:未知TZ UTC
Error: Unknown TZ UTC
并且无法读取csv.
我可以读取CSV的唯一方法是:
The only way I can read the CSV is this way:
read_csv("some_file.csv",locale=locale(tz="Australia/Sydney"))
悉尼是我的时区.
但是,我宁愿修复该错误,也不愿在可能的情况下解决该错误. 有人知道如何永久修复UTC错误吗?例如.启动说明? 塔.
But I'd rather fix the error than work around it if possible. Does anybody know how to fix the UTC error permanently? E.g. Startup instructions? Ta.
推荐答案
locale
输入参数设置为default_locale()
.当您打印出default_locale
函数时,您可以看到它是从options
的语言环境中读取的.
the locale
input argument is set to default_locale()
. When you print out the default_locale
function, you can see that it read in the locale from options
.
要永久设置语言环境,以便在每次启动R时都进行设置,可以将以下行添加到〜PATH_TO_R〜/etc/Rprofile.site
To set the locale permanently so that it is set every time you start R, you can add the following line to your ~PATH_TO_R~/etc/Rprofile.site
options(readr.default_locale=readr::locale(tz="Australia/Sydney"))
对于临时解决方案,只需在脚本顶部添加此行
For temporary solution, just add this line at the top of your script
这篇关于读取CSV的时区错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!