Saving Log window as a csv file in a macro

Hi all,

I want to save a text of Log window as a csv file.
my macro works for the “Results” table but not for the “Log” window
Here is my macro code.


name = getTitle;
dotIndex = indexOf(name, “.”);
name = substring(name, 0, dotIndex);
dir = getDirectory(“Choose a Directory”);
saveAs(“Results”, dir + name + “.csv”);

Thanks,
Fares

Good day Fares,

the basic question behind yours is: What do you expect from the “.csv”-format?

csv: Comma Separated Values

In other words, how are the values in the log-window arranged. Are they already comma separated and if not, how are they separated?

The macro commad

string = getInfo("log");

returns what is contained in the log window and you can save it per:

File.saveString(string, path);

If you need any formatting before the save, then please explain in detail.

Regards

Herbie

1 Like

Thanks Herbie,

In my Log window, the values are separated by space. However I want to save all these value in an EXCEL file in which each column will correspond on a column from the Log window.

Regards.
FB

Fares,

I don’t use excel but I’m pretty sure it will read space- or tab-delimited text files.

Save with a path

path = dir + name + ".txt";

and try to import to excel. If this doesn’t work properly, you could try to convert the spaces to tabs because tab-delimted files are standard and excel should be able to read them correctly.

Regards

Herbie

3 Likes