【发布时间】:2018-01-17 03:12:56
【问题描述】:
我希望我的 csv 文件作为一个数据库,用于存储我在运行程序时输入的数据。它应该继续添加名称
add_prob<-function()
ad<-as.integer(readline("Enter how many probables, you are going to add:
"))
df=data.frame(Reg=NA,Na=NA,Do=NA,Co=NA,E=NA)
for (i in 1:ad) {
dt<-Sys.Date()
Reg<-format(dt,format="%d %B % %Y")
Na<-readline("Enter the participant Name: ")
Do<-readline("Enter the domain he is working: ")
Co<-readline("Enter his mobile number: ")
E<-readline("Enter his E-mail ID: ")
df<-rbind(df,data.frame(Reg,Na,Do,Co,E))
}
write.csv(df, file="Training_Probables.csv", append=TRUE, row.names =
FALSE, quote = TRUE)
df=df[-1,]
names(df)=c("Date","Name","Domain","Mobile No.", "E-Mail ID")
print(df)
write.csv(df, file="Training_Probables.csv", append=TRUE, row.names =
FALSE, quote = TRUE)
【问题讨论】:
-
你想从命令行运行它,即打开一个终端并像
Rscript add_user_todb.r 'John' 'IT' '000-111-222' 'john@it.com'那样做某事并让r脚本自动将此条目附加到数据库吗?