help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to write the output of the code to .csv format and save the file


From: Nicholas Jankowski
Subject: Re: How to write the output of the code to .csv format and save the file
Date: Sat, 6 Jun 2020 08:25:45 -0400

On Sat, Jun 6, 2020, 7:48 AM Ganesh Kini <ganeshrkini19@gmail.com> wrote:
Hi,

But the output a set of Numeric and text string.

How can i save  the output in a csv file? do i need to put all my output values of the code to a Matrix then use csvwrite() function?



Please always keep the help list cc'd on all replies (Reply All) so others can contribute to the help, and the convention of this mailing list is to bottom post, not top post (see http://www.idallen.com/topposting.html, in Gmail you have to tap/click the three dots to show replies to be able to bottom post)

Anyway, csvwrite and dlmwrite only write numeric data, so they won't output text. But I do find it is the easiest way to save data. It would require reading the data, extracting just the numbers and putting them in an array, then saving that array with csvwrite.  Note that you can use the 'append' option to put the CSV data after some text header rows if you write them to a file first. See an example here:
https://www.mathworks.com/matlabcentral/answers/263227-dlmwrite-with-a-header

but If you want a mix of data and text within the file, you'll need to use the c-style functions to output formatted text, as I had linked below.  You'll have to read in the data (if its not already in memory) extract the data you want to rearrange, then write a script to output the data in the format you want using fprintf, fputs, etc.



if you want a mix of text and data, you'll probably need to use something like the c-style file i/o to create formatted text strings for writing.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]