Hello everyone,
Here’s my code :
function TypeFrame(objet)
findFrame = findall(x->occursin("frame =",x),objet)
sframe = []
for i in findFrame
lframe = objet[i]
sframe = [sframe;split(lframe,r"frame =| --> ")[2]]
end
return sframe
end
cd("C:/Users/L1028071/Documents")
for f in readdir()
out=open("FilteredFile.txt","w")
file = readlines(f)
findWindow = findall(x->occursin("Window",x),file)
for line in findWindow
if startswith(split(file[line]," --> ")[2],"Window")
write(out,file[line])
write(out,"\n")
end
end
close(out)
fichier = open("FilteredFile.txt") do file
f = readlines(file)
WindowType = TypeFrame(f)
end
end
With this code I read all the files in my directory, for each file I only keep a few lines ( if startswith(split(file[line]," → ")[2], “Window” …) that I will then write in a new text file (FilteredFile.txt). Once I’ve done that, I open this new file and apply a function that gives me an array.
Each time a new file from the directory is processed the file “FilteredFile.txt” is “overwritten” and then recreated with new data.
For example if I have two files in my directory I will get 2 distincts arrays :
Any[" ‘DataManager’“, " ‘LauncherFrame’”, " ‘DataManager’“, " ‘DataManager’”, " ‘DataManager’“, " ‘ToolBox’”, " ‘ToolBox’“, " ‘ToolBox’”, " ‘MonoWellInterpretationView’“, " ‘MonoWellInterpretationView’”, " ‘MonoWellInterpretationView’“, " ‘MonoWellInterpretationView’”, " ‘MonoWellInterpretationView’“, " ’ ‘ToolBox’”, " ‘DataManager’“, " ‘DataManager’”]
Any[" ‘DataManager’“, " ‘LauncherFrame’”, " ‘DataManager’“, " ‘DataManager’”, " ‘DataManager’“, " ‘ToolBox’”, " ‘ToolBox’“, " ‘ToolBox’”, " ‘MonoWellInterpretationView’“, " ‘MonoWellInterpretationView’”, " ‘MonoWellInterpretationView’“, " ‘MonoWellInterpretationView’”, " ‘MonoWellInterpretationView’“, , " ‘MonoWellInterpretationView’”, " ‘MonoWellInterpretationView’“, " ‘MonoWellInterpretationView’”, " ‘MonoWellInterpretationView’“, " ‘ToolBox’”, " ‘DataManager’“, " ‘DataManager’”]
I would like for any number of files in my directory to get a single array that contains the data of all the files.
I have already succeeded by not “overwriting” the “FilteredFile.txt” file each time a new file in the directory is processed. It works well when I only have 2 files in my directory but if I have 1000 I will end up with a huge “FilteredFile.txt” with thousands of lines which will take a long time to process.
So my problem is to keep overwriting the “FilteredFile.txt” file while “adding” somewhere the data of each file as we go along to have only one array.
I don’t know if I’ve made it clear and I thank you in advance for your answers and your help !