help-octave
[Top][All Lists]
Advanced

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

Re: How can I capture/save my original CSV column headings in a .mat fil


From: Philip Nienhuis
Subject: Re: How can I capture/save my original CSV column headings in a .mat file?
Date: Mon, 20 Apr 2015 10:11:09 -0700 (PDT)

bpabbott wrote
>> On Apr 19, 2015, at 6:16 PM, Farmer <

> gmatysiak@

> > wrote:
>> 
>> I've looked around on the site but cannot find what I'm looking for.
>> 
>> CSV data is downloaded to Octave without the column/heading descriptors
>> i.e.
>> a pure data matrix results. What would be the most efficient approach in
>> reading the original headings/column names in the csv file and name my
>> imported data vectors/columns, subsequently saving the file as a .mat
>> file?
>> For example, would it be possible to pre-prepare a list of names and
>> reference them, perhaps by way of a loop? 
>> 
>> Be very grateful for suggestions, as I'm sure I'm not the first to
>> encounter
>> this. Many thanks.
>> 
>> Farmer
> 
> I’ve written a script that does something very similar (csvload.m). It is
> attached.
> 
> You can use the script to load a csv-file into a structure whose
> field-names are taken from the column headers, and then save the data
> using the -struct option.
> 
>       s = csvload (your_csv_file, “returnstruct”, true, “headerlines”, 1);
>       save your_mat_file.mat -struct s
> 
> The script does more than you require. So you may wish to modify it to
> suit your needs.

You could also check if csv2cell() in the io package can help you.

Philip



--
View this message in context: 
http://octave.1599824.n4.nabble.com/How-can-I-capture-save-my-original-CSV-column-headings-in-a-mat-file-tp4669936p4669957.html
Sent from the Octave - General mailing list archive at Nabble.com.



reply via email to

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