-2
我希望將我的csv文件作爲數據庫存儲我每次運行程序時輸入的數據。它應該繼續添加姓名我想將csv文件作爲R編程中的數據庫
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)
的可能的複製[如何追加整個數據幀在R A CSV(https://stackoverflow.com/questions/25436737/how-to-append -a-whole-dataframe-to-a-csv-in-r) –
你是否想從命令行運行這個命令,即打開一個終端並像'Rscript add_user_todb.r'那樣做一些行爲'John''IT'000 -111-222''john @ it.com''並讓r腳本自動將這個條目添加到數據庫中? – davidski