[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Creating a csv with dlmwrite(..., "-append"): column names then data?
From: |
forkandwait |
Subject: |
Creating a csv with dlmwrite(..., "-append"): column names then data? |
Date: |
Mon, 23 Aug 2010 17:11:55 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
Hi all,
If one is creating a csv file and wants a row of column names on top of the
file, separated by delimiters, what is the best way to do it?
For example, a sample desired csv format might have this:
YEAR,CNTY001,CNTY003
1999,1000,1003
1998,987,200
What is the best way to write that top row programmatically? (I am looping over
a bunch of stuff and want to write a bunch of files.)
If dlmwrite allowed for cell arrays, I would do the following:
dlmwrite("foo.csv", {'YEAR', 'CNTY001', 'CNTY003'});
dlmwrite("foo.csv", matrix_w_data, "-append");
Other approaches include joining a string with commas as separators, monkey
business with sprintf, or??
Thanks!
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Creating a csv with dlmwrite(..., "-append"): column names then data?,
forkandwait <=