I'm working on something which I think is pretty easy to solve but I can't put all the necessary steps together.
Situation
I have a directory with .txt files (~17000, ~20gb sum) They all are structure more or less the same (they represent a bill of material) and have a separator in common.
What I want to do now is load all of these files into one single list, where on the second level are again lists, with the file name as the attribute. In this second level list the content of the text file should be a dataframe.
So to make it more explicit, I have files like this:
A1.txt
B1.txt
C1.txt
all with the more or less same structure but with different content (BOM). the design of the list should be something like this:
list of list
|list(named A1.txt)
$ Content of A1.txt as dataFrame
$ Content of other files concerning A1.txt (dataframe)
$ Content of A1.txt (other, e.g. timeseries)
|list(named B1.txt)
$ Content of B1.txt as dataFrame
$ Content of other files concerning B1.txt (dataframe)
$ Content of other files concerning B1.txt (other, e.g. timeseries)
I am quite new to R and so all I got until now is a dataframe of the textfile contents inside a list, but without the nomenclature and the nesting I would like to achieve, here the code so far:
list_of_lists <- list(1,2)
content <- read.delim(file, sep="|", header = FALSE, stringsAsFactors = FALSE) %>%
select(V1,V2,V3,V8,V14)
list_of_lists[[1]] <- as.data.frame(content)
Thank you already for help in advance