jc52766
jc52766

Reputation: 181

timezone error reading 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:

Error: Unknown TZ UTC

and csv is not read.

The only way I can read the CSV is this way:

read_csv("some_file.csv",locale=locale(tz="Australia/Sydney"))

Sydney being my timezone.

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.

Upvotes: 3

Views: 2624

Answers (1)

chinsoon12
chinsoon12

Reputation: 25225

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.

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

Upvotes: 5

Related Questions