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.

  • 5
    $\begingroup$ 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. $\endgroup$ – 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.

averages=Mean/@(data[[All, All, 2]]);

Edited to add:

enter image description here

| improve this answer | |
  • $\begingroup$ Thank you Sir, I will try it out $\endgroup$ – Dame Chrm Apr 30 '19 at 6:21
  • $\begingroup$ Sir, I cannot import all the CSV datas, I can import one CSV file $\endgroup$ – Dame Chrm Apr 30 '19 at 10:26
  • $\begingroup$ 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. $\endgroup$ – Kevin Ausman May 1 '19 at 0:31
  • $\begingroup$ Just made some example files and my original version works. FileNameList={"test1.csv","test2.csv","test3.csv"}; data=Import/@FileNameList; $\endgroup$ – Kevin Ausman May 1 '19 at 20:00
  • $\begingroup$ 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...." $\endgroup$ – Dame Chrm May 2 '19 at 9:26

Not the answer you're looking for? Browse other questions tagged or ask your own question.