Thread Subject: Importing csv data problem

Subject: Importing csv data problem

From: Tom Beaney

Date: 26 Oct, 2009 17:53:03

Message: 1 of 4

Hi there,

I'm having problems importing certain CSV files into Matlab.
I'm using the importdata function as my csv files have both text and numeric data
in and it gives me a nice pair of arrays in a structure. The problem is that I have
another set of csv files which for some reason will no import properly. I end up
with getting an array with a single column with all of the data from each line in one
big lump; numeric, text and commas all in one go.

I have tried modifying the csv files in notepad and wordpad and it seems to make
no difference. Does anyone out there have any suggestions or perhaps has had this
problem before.

Many thanks.

Subject: Importing csv data problem

From: someone

Date: 26 Oct, 2009 18:18:20

Message: 2 of 4

"Tom Beaney" <twbeaney@qinetiq.com> wrote in message <hc4nlv$28u$1@fred.mathworks.com>...
> Hi there,
>
> I'm having problems importing certain CSV files into Matlab.
> I'm using the importdata function as my csv files have both text and numeric data
> in and it gives me a nice pair of arrays in a structure. The problem is that I have
> another set of csv files which for some reason will no import properly. I end up
> with getting an array with a single column with all of the data from each line in one
> big lump; numeric, text and commas all in one go.
>
> I have tried modifying the csv files in notepad and wordpad and it seems to make
> no difference. Does anyone out there have any suggestions or perhaps has had this
> problem before.
>
> Many thanks.

Just to be sure, you are using xlsread, right?

And not csvread, wk1read, or dlmread, right?

Are you sure they are all simply *.csv files
(made with the same version of EXCEL)?

Subject: Importing csv data problem

From: Leslie McBrayer

Date: 26 Oct, 2009 20:15:06

Message: 3 of 4

> I'm having problems importing certain CSV files into Matlab.
> I'm using the importdata function as my csv files have both text and
> numeric data
> in and it gives me a nice pair of arrays in a structure. The problem is
> that I have
> another set of csv files which for some reason will no import properly. I
> end up
> with getting an array with a single column with all of the data from each
> line in one
> big lump; numeric, text and commas all in one go.

The importdata function can recognize text as column or row headers, but not
any other columns of nonnumeric data (where nonnumeric is any text,
including formatted dates or times). I suspect that the files that you
cannot import have columns with text, where the text is not in the first
column(s).

You could try specifying a range of data to import with dlmread (to avoid
the text), or use textscan (to get both numeric and text).

Leslie

Subject: Importing csv data problem

From: Vedanth Bilagi

Date: 10 Dec, 2010 11:01:05

Message: 4 of 4


Hey Tom,

How did you solve this problem. Even I am facing hte same issue.

Thanks,
Vedanth



"Tom Beaney" <twbeaney@qinetiq.com> wrote in message <hc4nlv$28u$1@fred.mathworks.com>...
> Hi there,
>
> I'm having problems importing certain CSV files into Matlab.
> I'm using the importdata function as my csv files have both text and numeric data
> in and it gives me a nice pair of arrays in a structure. The problem is that I have
> another set of csv files which for some reason will no import properly. I end up
> with getting an array with a single column with all of the data from each line in one
> big lump; numeric, text and commas all in one go.
>
> I have tried modifying the csv files in notepad and wordpad and it seems to make
> no difference. Does anyone out there have any suggestions or perhaps has had this
> problem before.
>
> Many thanks.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
csv Tom Beaney 26 Oct, 2009 13:54:06
importdata Tom Beaney 26 Oct, 2009 13:54:06
rssFeed for this Thread

Contact us at files@mathworks.com