[Top][All Lists]

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

Re: using xlswrite csvwrite

From: fork
Subject: Re: using xlswrite csvwrite
Date: Wed, 6 Apr 2011 22:06:06 +0000 (UTC)
User-agent: Loom/3.14 (

senator <senator314159 <at>> writes:

> I need to be able to write and read csv files and csv write and read do work
> great for me as long as I dont write any text to the file.   I would like to
> be able to find a way to put a field column on the top of my data in a csv
> file. It works great writing the data to a csv file, but i want to be able
> to write the field row on the top row in text. In matlab it works by doing 
> 2 seperate csv writes (one for data and one for text). I dont know if that
> would work however because octave seems to erase everything else in a file
> before it writes.
> I dont know if xlswrite will let me write to a csv file, but if it does
> getting xlswrite to work could solve my problem.

I don't know if it is helpful, but I can't help but get a little "meta" on your
particular problem:

I would recommend avoiding excel and other binary / proprietary formats like the
plague (which they are).  They generally poorly supported in the Free Software
world, require lots of dependencies (Java, DDE, etc, etc, etc), and won't be
portable outside of a Windows environment.  CSV files will ALWAYS be importable,
human readable/ editable, and will require the bare minimum of infrastructure to
use.  If you need to get fancy, look into CDF or HDF (which I don't know much
about, or I would try to say something intelligent...)

I suggest you use dlmwrite to output CSV files, or perhaps write a function that
adds a header line using dlmwrite in conjunction with printf.  (csvwrite is a
nonstandard wrapper to dlmwrite, as far as I understand.)  Octave has enough
built in I/O functions you should be able to do anything you want with a little
bit of coding (which is good for you anyway ;) )  dlmwrite has lots of useful
options, including an "append" flag for putting data after a header row, which
you can learn about here:

If you just need to save files and communicate between octave scripts, simply
use "save" and "load", which can be found on the same page.

I would ONLY use xlswrite and friends if you MUST communicate with a (L)user who
insists on opening only files that end in ".xls"; even then, some patient
explaining about the virtues of simple, non-proprietary CSV formats can save you
both 100s of wasted man-hours in the future.

If your data is heterogeneous in its columns (some text, some number columns),
that is another problem altogether -- if so, please let us know.

My apologies if my rant/ tangent is too tangential or vague to be useful..

reply via email to

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