I am working with a lot of daily weather files in the txt
format. I need to calculate a daily quantity from each of them, e.g., daily light intensity, which involves a simple summation of the light intensity column in Excel. As I am working with over three years of data, it is not possible to do this manually.
How can I automate this in Mathematica? Currently I import all the files using the following method. (Example shown is for Jan 1 to Jan 31)
filenames = FileNames[];
TestList = Flatten[Table[Files[[j, i]], {j, 1, 31}, {i, 2, 1437}], 1];
LightIntensity = TestList[[1 ;;, 5]];
DailyLightIntensity = Partition[LightIntensity, 1436];
DailySummation = Table[Total[DailyLightIntensity[[i]]], {i, 1, 31}]
The method above only works assuming all the txt
files contain rows from 2 to 1436, so I can use Partition
, but I also need to handle cases with missing data.
I want to automate this process with Mathematica , import each txt
file separately, perform the necessary calculations, and store the answer. How can this be done?
The naming convention of the txt is given below:
[112] 2012-01-01
[112] 2012-01-02
[112] 2012-01-03
[112] 2012-01-04
...
[112] 2012-12-31
Paritition
for? $\endgroup$