Anyhow, I am writing a program that takes a bunch of output from a real-time system at 10ms loops and writes them to a comma-separated file. I can output the file just fine. Everything is working there.
However, as you can imagine, at 10ms loops the CSV blows up in size pretty quick.
I was hoping to ZIP up the ole' file before writing it to disk so that way it wouldn't take up as much space (our post-processing tools can unzip files so that's not a big deal).
Anyhow, do you think I should just write the .CSV as I have it now, zip it to a new .ZIP file, and then delete the temporary (raw) CSV or is there a way to do it off the bat?
Here is some code that I use now. Dont mind most of the loops, its really a PITA to get the data from the API of the real-time application. I just wanted to show you guys that I create a steam and write it to a csv.
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
if ((myStream = saveFileDialog1.OpenFile()) != null)
{
StreamWriter wText = new StreamWriter(myStream);
// write model name
wText.WriteLine("Model Name: " + tg.GetAppName());
// write model version
int[] temp;
temp = (int[])(Array)tg.GetSignalidsfromLabel("SIG_MODEL_VERSION");
wText.WriteLine("Model Version: " + tg.GetSignal(temp[0]));
// write system tunable parameters version
temp = (int[])(Array)tg.GetSignalidsfromLabel("SIG_PARAMETERS_TUNABLE_VERSION");
wText.WriteLine("Tunable Parameters Version: " + tg.GetSignal(temp[0]));
// write system nontunable parameters version
temp = (int[])(Array)tg.GetSignalidsfromLabel("SIG_PARAMETERS_NONTUNABLE_VERSION");
wText.WriteLine("Nontunable Parameters Version: " + tg.GetSignal(temp[0]));
//write time header
wText.Write("Execution Time,");
//write signal names to signal header
for (int i = 0; i < sig_names.Count; i++)
{
System.Array sig_index_array = (Array)sig_indexes[i];
int z = 0;
for (int y = 0; y < sig_index_array.GetLength(0); y++)
{
// simulink arrays not zero index (start at 1)
z = y + 1;
wText.Write(sig_names[i] + z.ToString() + ',');
}
}
wText.Write("\r\n");
//write time stamps and vaules to file
for (int i = 0; i < sig_values.Count; i = i + 3)
{
//write time stamp at start of get
wText.Write(sig_values[i].ToString() + ", ");
//write signal values
double[] sig_text_array = (double[])(Array)sig_values[i + 1];
for (int y = 0; y < sig_text_array.GetLength(0); y++)
wText.Write(sig_text_array[y].ToString() + ", ");
//write time stamp at end of get
wText.Write(sig_values[i + 2].ToString() + "\r\n");
}
wText.Close();
sig_values.Clear();
}
This post has been edited by killnine: 19 July 2007 - 08:27 AM

New Topic/Question
Reply




MultiQuote






|