Assume the following code (Below code is just an example to clearly illustrate my problem):
Res = {};
Iterations = 5;
Do[
Results = AppendTo[Res, i^2]
, {i, 1, Iterations}];
I have 2 questions:
I want to save the results in each iteration in an identical excel file (.xls file). In the end, when the iterations are finished, I will have one Excel file with all the results in it.
I tried to make the code more faster and elegant using
Scan[]
, but I failed to do it and I couldn't do that.(It is good to mention that I am just a rookie Mathematica programmer and I don't have much experience in it!).
Could you please help me with these poroblems ?
Do
is in no way a recursive construct. Are you sure you mean recursive? $\endgroup$Export
for excel files can only write content in one go. Of course you can completely overwrite the file for each line, which is inefficient but probably not too problematic. Other than that I see the following possibilities: write to a text file (or CSV) line by line, for these appending is simple and efficient. Depending on the data, you won't loose much compared to an excel file. If you really need excel, you could use NETLink to do what you want, if you search for "NET excel" you'll find many Q+A to start... $\endgroup$