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: Fri, 5 Jun 2020 16:39:06 -0400

On Fri, Jun 5, 2020 at 1:58 PM Ganesh Kini <ganeshrkini19@gmail.com> wrote:
place = ivc, val_a = 3.0000, close_a = 3.2806, diff_a = -0.0935, val_b = 3.0000, close_b = 2.8365, diff_b = 0.0545 X = 0.3, Y = -1.5, temp = 40
place = ivc, val_a = 3.0000, close_a = 3.1910, diff_a = -0.0637, val_b = 3.0000, close_b = 2.6977, diff_b = 0.1008 X = 0.3, Y = -1.5, temp = 150
place = ivc, val_a = 3.0000, close_a = 2.5851, diff_a = 0.1383, val_b = 3.0000, close_b = 2.9607, diff_b = 0.0131 X = 0.0, Y = -2.4, temp = 200
This is the output of my code has more than 10000 entries, but only shown 3 lines for reference. now i want it to be in this .csv format as follows
Place, ivc, ivc, ivc
repeated place, t, f, f, f
temperature, 40,150,200
X, 0.3,0.3,0.3
Y, -1.5, -1.5, -2.4
filename :: / folder / filename.csv
t test :: A_B_C: location_gif: 1, t, t, t
% Description
Place: There we enter the place
Repeated place: t - is true, just add f for all the places that you add (since there are 3 places we have 3 times f)
Temperature: is the temperature (in this example -40 150 200)
X and Y as separate variables
filename: add the path of the file
t test :: A_B_C: location_gif: 1, t, t, t,
The number of "t" s corresponding to the number of places.
So how do i write it? and also how do i link the output of the code and save it in .csv format? Kindly help

if you were just saving numerical data, you can create the array and save it as a csv with 'dlmwrite'. see the different function definitions at:
https://octave.org/doc/v5.2.0/Simple-File-I_002fO.html  

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.
https://octave.org/doc/v5.2.0/C_002dStyle-I_002fO-Functions.html

If your output data is just a nicely formatted text string, you'll probably want to use the same c-style functions to read the data line by line, extract the data into variables, and save them into a csv file via the functions described in the above help files.

reply via email to

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