如何导入多个文件并保存到多个数据文件?

时间:2022-02-20 22:48:09

instead of,

相反的,

split1<- read.csv("C:/Users/Admin/Documents/intern/splitstx/splitstx (1).csv")
split2<- read.csv("C:/Users/Admin/Documents/intern/splitstx/splitstx (2).csv")
.
.
.
split36<- read.csv("C:/Users/Admin/Documents/intern/splitstx/splitstx (36).csv")

I did not want to save in 1 files since when all combine, it consist of 5GB csv data and my ram didnt support it. So is there any other solution?

我不想保存一个文件,因为当所有文件合并时,它包含5GB的csv数据,而我的ram不支持它。还有其他的解决办法吗?

1 个解决方案

#1


0  

All you want to do is merge the data in the CSV files? Try something like this.

你要做的就是合并CSV文件中的数据?这样的尝试。

library(data.table)
setwd("C:/Users/xxx/Merge Multiple CSV Files/CSV Files/")

WD="C:/Users/xxx/Merge Multiple CSV Files/CSV Files/"
data<-data.table(read.csv(text="CashFlow,Cusip,Period"))

csv.list<- list.files(WD)
k=1

for (i in csv.list){
  temp.data<-read.csv(i)
  data<-data.table(rbind(data,temp.data))

  if (k %% 100 == 0)
    print(k/length(csv.list))

  k<-k+1
}

#1


0  

All you want to do is merge the data in the CSV files? Try something like this.

你要做的就是合并CSV文件中的数据?这样的尝试。

library(data.table)
setwd("C:/Users/xxx/Merge Multiple CSV Files/CSV Files/")

WD="C:/Users/xxx/Merge Multiple CSV Files/CSV Files/"
data<-data.table(read.csv(text="CashFlow,Cusip,Period"))

csv.list<- list.files(WD)
k=1

for (i in csv.list){
  temp.data<-read.csv(i)
  data<-data.table(rbind(data,temp.data))

  if (k %% 100 == 0)
    print(k/length(csv.list))

  k<-k+1
}