Created
March 27, 2019 16:17
-
-
Save bdemeshev/4f2cc2a981ce24c85363d9bd3a0db07c to your computer and use it in GitHub Desktop.
[Импорт-экспорт русских файлов в R] #code #r
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sys.setlocale(category = "LC_CTYPE", locale = "russian") | |
# try | |
foo = rio::import("data.txt") | |
foo = readr::read_csv2("data.txt") | |
foo = data.table::fread("data.txt", header=TRUE, sep="|", sep2=".") | |
# check! | |
# 1. cyrillic letters visible in environment | |
# 2. cyrillic letters in | |
View(foo) | |
# 3. cyrillic letter in | |
glimpse(foo) | |
# try | |
# to save xlsx | |
export(data, "data_exported.xlsx") | |
# to save csv with cyrillic letters | |
export(data, "data_exproted.csv", format = ";", fileEncoding = "CP1251", fwrite = FALSE) | |
# to open the file in Excel use: | |
# data/import, select CP1251 encoding, enjoy :) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment