Formatting and Writing data into .csv file

berto's icon

Dear all, this is my very first post after some years of using Max...
I have checked similar topics on the forum but I can't find something related.

I am trying to save a series of variables (that continuously change) as a .csv file, since I would like to open and work on them in Excel.
Having -let's say- three variables, I would like to record every new update into a new line, but keeping the division into (in this case) three columns.
Basically I would like to get something like this:

Data1 | Data2 | Data 3
1 3 6
5 6 2
2 8 15
12 16 18
22 4 1
... ... ...

I tried first to write a .csv file with [coll]. Getting every new line it's not an issue, but if I open the text file with Excel I can't see the three variables separated in different 'columns', but all of them in one.
Then, I tried to format my variables with a [sprintf] and writing them on a file using [text].
This seems to be probably a better way, but I can't add the equivalent of a new line \n in the [sprintf] object or using the carriage return (cr) message with [text]. I mean, it doesn't really do a carriage return...
To me, it seems that there should be a way of doing something like [sprintf %f %f %f\n]...but it's not working.

I don't know if someone has already done something like this or it has a suggestion...is this approach too simplistic ?

webe's icon

Bump

Floating Point's icon

this works:

Max Patch
Copy patch and select New From Clipboard in Max.

webe's icon

Yes, the [sprintf %f\\,%f\\,%f] worked for me too. Thanks!