I am trying to read multiple csv files and want to plot them all together, Lets say I have 3 files, file1 , file2 and file3 I want to average 3 files, and plot them all together, So far I have set up like this:
SetDirectory[NotebookDirectory[]]
and I load files like this:
files = FileNames[NotebookDirectory[] <> "*.csv"];
Do[Print["Processing file ", files[[n]]];
processFile[files[[n]]], {n, 1, Length[files]}]
processFile[fileName_]:=
Module[{data2},
data2 = Import[fileName, "Data"];
tables = Table[data2[[i]], {i, 1, Length[data2]}]]
now, here is where I have problem:
I am giving a name for each processFile
and do other calculations:
d1 = processFile["file1.csv"];
d2 = processFile["file2.csv"];
d3 = processFile["file3.csv"];
avg = (d1 + d2 + d3)/3;
avgplot = ListPlot[avg, PlotRange -> {{0, 100}, {0, 1}}];
I am having trouble automating d1,d2,d3 (I want this automated to no matter how many files I have and so I don't have to manually insert their names and define multiple times)
Thanks for your help.
files // Map[processFile[#]&] // Mean
? $\endgroup$