Difference between revisions of "Software tutorial/Loading data in MATLAB or Python"

From Process Model Formulation and Solution: 3E4
Jump to navigation Jump to search
m
m
Line 13: Line 13:
| width="40%" valign="top" |  
| width="40%" valign="top" |  
<tt>xlsread(...)</tt> and <tt>xlswrite(...)</tt>
<tt>xlsread(...)</tt> and <tt>xlswrite(...)</tt>
Can read both the text and values in an Excel file.  Cell containing formulas are imported as the result of the formula value.
Can read both the text and values in an Excel file.  Cell containing formulas are imported as the result of the formula value.
| width="40%" valign="top" |
| width="40%" valign="top" |
Excel files
Excel files in Python
|-
|-
[http://en.wikipedia.org/wiki/XML XML files] are rapidly becoming a fairly standard import and export format for data, because it describes both the data and the nature of the data in the file.
| [http://en.wikipedia.org/wiki/Comma-separated_values Comma-separated value (CSV) files] are a standard format for many years and can be read on any system, since they are pure text files.
| <tt>csvread(...)</tt> and <tt>csvwrite(...)</tt>
| CSV in Python
|-
| [http://en.wikipedia.org/wiki/XML XML files] are rapidly becoming a fairly standard import and export format for data, because it describes both the data and the nature of the data in the file.
|
|
<tt>xmlread</tt> and <tt>xmlwrite(...)</tt>.
<tt>xmlread(...)</tt> and <tt>xmlwrite(...)</tt>.
|
|
XML Python
XML Python
|}
|}

Revision as of 16:57, 2 December 2010

A number of people asked me how to load data into MATLAB and Python after our class on the poor ability of spreadsheets to do serious engineering calculations.

Here are some functions that you can use in either language.

File format MATLAB Python

Excel files

xlsread(...) and xlswrite(...)

Can read both the text and values in an Excel file. Cell containing formulas are imported as the result of the formula value.

Excel files in Python

Comma-separated value (CSV) files are a standard format for many years and can be read on any system, since they are pure text files. csvread(...) and csvwrite(...) CSV in Python
XML files are rapidly becoming a fairly standard import and export format for data, because it describes both the data and the nature of the data in the file.

xmlread(...) and xmlwrite(...).

XML Python