Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Member Login

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Eng-Tips
*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I just wanted to say that you guys RULE, a million thank you's to whoever created, and/or manages this site. KEEP UP THE GOOD WORK..."

Geography

Where in the world do Eng-Tips members come from?
rm2 (Mechanical)
7 Apr 09 18:40
Hello,

I am trying to use the textscan command to work a csv file we generate on a test stand.
First I have 115 strings as headers, for this I thought of:

C_text = textscan(fid, '%s', 115, 'delimiter', ',');

I need to ignore/erase the first two. I find it unpractical to write the 113 %s and the two %*s.
Any ideas?

Then I am thinking on getting the results (below each of the 113 strings) , strings and numbers, to start working on them for statistical analysis (histogram, percent failures, codes, etc). For this data, the first 4 are strings, then f f, then s,  f f f ..113th f.

Something like this:

'%s''%s''%s''%s''%f''%f''%s''%f''%f''%f''%f'...'%f'

I do not want to right down the hole chain, any ideas?

I am attaching the file so you can take a look. The final purpose is to pull each file for every day and not waste time trying to make the summary of the results.

I appreciate your help.
thanks
 
rm2 (Mechanical)
9 Apr 09 0:07
Found some code.
I will need to change the number of rows depending on the size of the file.

From the data already gathered, I am on a dilema, should I create a separate variable from each column to easly start plotting them or should I work out each of the variables at "data" ? Please take a look to the code and let me know your thoughts.  Is it possible to have at the x axis both date/time  and Serial Number (obviously, matched) ? how can I change the scale of the y axis ?


function data=dataimport
% Import data from DRC_50HP_Stand1_090406.csv
% Automatically generated 08-Apr-2009

% Define parameters
fileName='C:\Users\Robert\Documents\MATLAB\DRC_50HP_Stand1_090406.csv';
numHeaderLines=7;
formatString='%q%q%q%q%f%f%q%f%f%u64%f%f%f%f%f%f%f%f%f%f%f%u64%f%u64%f%f%f%f%u64%f%f%f%f%f%u64%f%f%f%f%f%f%f%f%f%f%f%u64%u64%u64%f%f%f%f%u64%f%f%f%f%f%u64%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f';
numRows=71;

% Read data from file
fid=fopen(fileName,'rt');
ignoreColumns=zeros(1,0);
columnHeaderRowNumber=4;
columnHeaderRowString=textscan(fid,'%s',1,'headerlines',columnHeaderRowNumber-1,'delimiter','\n');
columnHeaderRow=textscan(columnHeaderRowString{1}{1},repmat('%s',1,113),1,'delimiter',',');
columnNames=columnHeaderRow;
columnNames(ignoreColumns)=[];
dataCell=textscan(fid,formatString,numRows,'headerlines',numHeaderLines-columnHeaderRowNumber,'delimiter',',');

% Convert to 2D Cell
data=cell(numRows+1,length(dataCell)); %Preallocate
data(1,:)=columnNames; % Start with column names

for k=1:length(dataCell)
    if iscell(dataCell{k}) % If cell array of strings
        data(2:end,k)=dataCell{k};
    else % If numerical
        data(2:end,k)=mat2cell(dataCell{k},ones(numRows,1),1);
    end
end
status=fclose(fid);



I really appreciate your help, thanks
 

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close