Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Importing several CSV files at the same time (600 or more)

Subject: Importing several CSV files at the same time (600 or more)

From: BO

Date: 1 Oct, 2007 15:30:55

Message: 1 of 7

Hey! i need to import around 400-600 csv files to the workspace at the same time so i can take the data in those file and graph it, the issue is that i have to this trough a Gui, and using uiimport takes a lot of time. Is there a way that i can import that many files, and let the user of the gui select de directory and the number of files.
type of files: CSV files, with 3 colums each colum a variable with around 8192 points.

Subject: Importing several CSV files at the same time (600 or more)

From: G.A.M.

Date: 1 Oct, 2007 19:33:20

Message: 2 of 7

BO <bianca_osorio@hotmail.com> wrote in message
<5497789.1191252685630.JavaMail.jakarta@nitrogen.mathforum.org>...
> Hey! i need to import around 400-600 csv files to the
workspace at the same time so i can take the data in those
file and graph it, the issue is that i have to this trough a
Gui, and using uiimport takes a lot of time. Is there a way
that i can import that many files, and let the user of the
gui select de directory and the number of files.
> type of files: CSV files, with 3 colums each colum a
variable with around 8192 points.

This code doesn't include a feature for limiting the number
of files in a directory, but you could add that easily:

%let user select directory from UI,
%and pass this directory as a parameter
function ProcessFiles(directory)
allFiles = dir(directory);
for k = 1 : length(allFiles)
if(strfind(allFiles(k).name, '.csv'))
processFile([directory '\' allFiles(k).name]);
end
end
end

Subject: Importing several CSV files at the same time (600 or more)

From: BO

Date: 2 Oct, 2007 12:53:01

Message: 3 of 7

Hey Thank u for ur answer.. i try the code u said.. just with the directory i want... to see what it does..
%let user select directory from UI,
%and pass this directory as a parameter
function ProcessFiles ('C:\Users\Biankita\Documents\EQUIMAVENCA\DATA\RD04-1\FFTs\*.csv');
allFiles = dir('C:\Users\Biankita\Documents\EQUIMAVENCA\DATA\RD04-1\FFTs\*.csv');
for k = 1 : 100(allFiles)
if(strfind(allFiles(k).name, '.csv'))
processFile([C:\Users\Biankita\Documents\EQUIMAVENCA\DATA\RD04-1\FFTs '\' allFiles(k).name]);
end
end
end
 but i get this...
??? Error: File: ProcessFiles.m Line: 3 Column: 24
Missing MATLAB operator

Subject: Importing several CSV files at the same time (600 or more)

From: "G.A.M.

Date: 2 Oct, 2007 14:21:53

Message: 4 of 7

On Oct 2, 8:53 am, BO <bianca_oso...@hotmail.com> wrote:
> Hey Thank u for ur answer.. i try the code u said.. just with the directory i want... to see what it does..
> %let user select directory from UI,
> %and pass this directory as a parameter
> function ProcessFiles ('C:\Users\Biankita\Documents\EQUIMAVENCA\DATA\RD04-1\FFTs\*.csv');
> allFiles = dir('C:\Users\Biankita\Documents\EQUIMAVENCA\DATA\RD04-1\FFTs\*.csv');
> for k = 1 : 100(allFiles)
> if(strfind(allFiles(k).name, '.csv'))
> processFile([C:\Users\Biankita\Documents\EQUIMAVENCA\DATA\RD04-1\FFTs '\' allFiles(k).name]);
> end
> end
> end
> but i get this...
> ??? Error: File: ProcessFiles.m Line: 3 Column: 24
> Missing MATLAB operator

I see several potential issues:
1. Did you write the function "processFile"?
2. The parameter to your main function (ProcessFiles) should probably
be: 'C:\Users\Biankita\Documents\EQUIMAVENCA\DATA\RD04-1\FFTs'
3. You are missing the single quotes on your first parameter to
processFile.
4. your for-loop syntax looks incorrect.

Subject: Importing several CSV files at the same time (600 or more)

From: Dan Hensley

Date: 2 Oct, 2007 14:24:13

Message: 5 of 7

BO wrote:
> Hey! i need to import around 400-600 csv files to the workspace at the same time so i can take the data in those file and graph it, the issue is that i have to this trough a Gui, and using uiimport takes a lot of time. Is there a way that i can import that many files, and let the user of the gui select de directory and the number of files.
> type of files: CSV files, with 3 colums each colum a variable with around 8192 points.

This is a FAQ:

http://www.mit.edu/~pwb/cssm/matlab-faq.html#loopoverfiles

Dan

Subject: Importing several CSV files at the same time (600 or more)

From: Peter Boettcher

Date: 2 Oct, 2007 16:33:22

Message: 6 of 7

BO <bianca_osorio@hotmail.com> writes:

> Hey Thank u for ur answer.. i try the code u said.. just with the
> directory i want... to see what it does..

> %let user select directory from UI,
> %and pass this directory as a parameter
> function ProcessFiles ('C:\Users\Biankita\Documents\EQUIMAVENCA\DATA\RD04-1\FFTs\*.csv');
> allFiles = dir('C:\Users\Biankita\Documents\EQUIMAVENCA\DATA\RD04-1\FFTs\*.csv');
> for k = 1 : 100(allFiles)
> if(strfind(allFiles(k).name, '.csv'))
> processFile([C:\Users\Biankita\Documents\EQUIMAVENCA\DATA\RD04-1\FFTs '\' allFiles(k).name]);
> end
> end
> end
> but i get this...
> ??? Error: File: ProcessFiles.m Line: 3 Column: 24
> Missing MATLAB operator

You were not supposed to replace "directory" with your directory. It
was supposed to be a function which you called using your directory as
a parameter.

If you don't know what I am talking about, take a break from this task
and read the "Getting Started" part of the MATLAB documentation.

-Peter

Subject: Importing several CSV files at the same time (600 or more)

From: jason

Date: 18 Mar, 2014 02:35:12

Message: 7 of 7

this code is ambiguous as to what it does. there is no processfile in matlab help.

Tags for this Thread

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.

Contact us