# Performing loop operation (average on lists of datas) of strings of datas [closed]

Lets say I have 100 CSV files of two columns data in each file, and I want to calculate the average of the 2nd column of each CSV file and then save all all these 100 averaged values in one CSV file (in one column) and then plot this CSV file of averaged values with respect to another CSV file having one column (100 datas in it)

Please give me a mathematica code for this.

• I'm voting to close this question as off-topic because there is no well-posed question in this post; the OP is simply asking for somebody to act as a free coding service. – m_goldberg Apr 30 '19 at 9:30

Assume you have a list, FileNameList, of your file names, and that they all explicitly have .csv as the extension.

data=Import/@FileNameList;
averages=Mean/@(data[[All, All, 2]]);
Export["averages.csv",averages]
xdata=Import["otherfile.csv"];
ListPlot[Transpose[{xdata,averages}]]


• Thank you Sir, I will try it out – Dame Chrm Apr 30 '19 at 6:21
• Sir, I cannot import all the CSV datas, I can import one CSV file – Dame Chrm Apr 30 '19 at 10:26
• Ok, then something like: data=Table[Import[FileNameList[[i]]],{i,Length[FileNameList]}] should work. I don't have your data files, so I couldn't test. – Kevin Ausman May 1 '19 at 0:31
• Just made some example files and my original version works. FileNameList={"test1.csv","test2.csv","test3.csv"}; data=Import/@FileNameList; – Kevin Ausman May 1 '19 at 20:00
• Yes, I did just that (files in FileNameList folder), it does read the files in the output, but while doing (averages=Mean/@(data[[All, All, 2]])), instead of giving list of average values of each CSV files, it instead give a list of words as "mean striongs, meanstrings...." – Dame Chrm May 2 '19 at 9:26