Last active
January 26, 2022 09:03
-
-
Save AkiyukiOkayasu/8bb35a8517b8830e5ec932c3473cfd34 to your computer and use it in GitHub Desktop.
大量のCSVファイルをSAVファイルに変換する
This file contains hidden or 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
#install.packages("tidyverse")#ライブラリのインストール(初回のみ) | |
library(haven) | |
print(getwd())# 作業ディレクトリ | |
l <- list.files(pattern=".csv")# CSVファイルを検索、リスト化 | |
for (e in l) { | |
print(paste0(e, ".sav")) | |
df <- read.csv(e)#CSV読み込み | |
write_sav(df, paste0(e, ".sav"))#SAV書き出し | |
} |
This file contains hidden or 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
find . -name "*.csv" | xargs sed -i "" "s/,\$//" |
This file contains hidden or 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
find . -name "*.csv" | xargs nkf -w --overwrite -d; find . -name "*.csv" | xargs sed -i "" "s/,\$//" |
This file contains hidden or 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
find . -name "*.csv" | xargs nkf -w --overwrite -d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment