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:
read a csv

Subject: read a csv

From: Eleftheria Paidousi

Date: 12 Dec, 2012 18:37:08

Message: 1 of 7

i have a .csv file with mixed data and i want to process it with matlab , delete some rows or columns only under some conditions , How can i do it?! I tried textscan but i think that i can change no element .... What should i do?!?!

Subject: read a csv

From: someone

Date: 12 Dec, 2012 20:18:08

Message: 2 of 7

"Eleftheria Paidousi" <fridomaki@yahoo.gr> wrote in message <kaaisk$8gv$1@newscl01ah.mathworks.com>...
> i have a .csv file with mixed data and i want to process it with matlab , delete some rows or columns only under some conditions , How can i do it?! I tried textscan but i think that i can change no element .... What should i do?!?!

doc textscan

% Look at Example 9
% It shows you how to do exactly what you're asking.
% (If I understand the question.)

Subject: read a csv

From: Eleftheria Paidousi

Date: 12 Dec, 2012 21:20:14

Message: 3 of 7

I can't undrestand what you are saying to me
what is doc textscan?? is it diferent from the comand textscan and where is the example 9

Subject: read a csv

From: dpb

Date: 12 Dec, 2012 21:24:33

Message: 4 of 7

On 12/12/2012 3:20 PM, Eleftheria Paidousi wrote:
> ... what is doc textscan??

A suggestion to type in at the command line...

--

Subject: read a csv

From: Ehsan

Date: 13 Dec, 2012 09:54:08

Message: 5 of 7

"Eleftheria Paidousi" <fridomaki@yahoo.gr> wrote in message <kaaisk$8gv$1@newscl01ah.mathworks.com>...
> i have a .csv file with mixed data and i want to process it with matlab , delete some rows or columns only under some conditions , How can i do it?! I tried textscan but i think that i can change no element .... What should i do?!?!



try:
a=importdata(filename);
b=a.textdata(cellnumber:cellnumber,1);

or
name=xlsread(filename,'A19:X8778')

Subject: read a csv

From: Eleftheria Paidousi

Date: 13 Dec, 2012 15:55:09

Message: 6 of 7

> try:
> a=importdata(filename);
> b=a.textdata(cellnumber:cellnumber,1);
 
>> b=a.textdata(17:45212,1);
Attempt to reference field of non-structure array.

> or
> name=xlsread(filename,'A19:X8778')
doesn't read categorical data!

my data set is like

age job marital education default balance housing loan contact day month duration campaign pdays previous poutcome y
30 unemployed married primary no 1787 no no cellular 19 oct 79 1 -1 0 unknown no
33 services married secondary no 4789 yes yes cellular 11 may 220 1 339 4 failure no
35 management single tertiary no 1350 yes no cellular 16 apr 185 1 330 1 failure no
30 management married tertiary no 1476 yes yes unknown 3 jun 199 4 -1 0 unknown no
59 blue-collar married secondary no 0 yes no unknown 5 may 226 1 -1 0 unknown no
35 management single tertiary no 747 no no cellular 23 feb 141 2 176 3 failure no
36 self-employed married tertiary no 307 yes no cellular 14 may 341 1 330 2 other no
39 technician married secondary no 147 yes no cellular 6 may 151 2 -1 0 unknown no
41 entrepreneur married tertiary no 221 yes no unknown 14 may 57 2 -1 0 unknown no


or

"age";"job";"marital";"education";"default";"balance";"housing";"loan";"contact";"day";"month";"duration";"campaign";"pdays";"previous";"poutcome";"y"
30;"unemployed";"married";"primary";"no";1787;"no";"no";"cellular";19;"oct";79;1;-1;0;"unknown";"no"
33;"services";"married";"secondary";"no";4789;"yes";"yes";"cellular";11;"may";220;1;339;4;"failure";"no"
35;"management";"single";"tertiary";"no";1350;"yes";"no";"cellular";16;"apr";185;1;330;1;"failure";"no"
30;"management";"married";"tertiary";"no";1476;"yes";"yes";"unknown";3;"jun";199;4;-1;0;"unknown";"no"
59;"blue-collar";"married";"secondary";"no";0;"yes";"no";"unknown";5;"may";226;1;-1;0;"unknown";"no"
35;"management";"single";"tertiary";"no";747;"no";"no";"cellular";23;"feb";141;2;176;3;"failure";"no"
36;"self-employed";"married";"tertiary";"no";307;"yes";"no";"cellular";14;"may";341;1;330;2;"other";"no"
39;"technician";"married";"secondary";"no";147;"yes";"no";"cellular";6;"may";151;2;-1;0;"unknown";"no"
41;"entrepreneur";"married";"tertiary";"no";221;"yes";"no";"unknown";14;"may";57;2;-1;0;"unknown";"no"
43;"services";"married";"primary";"no";-88;"yes";"yes";"cellular";17;"apr";313;1;147;2;"failure";"no"
39;"services";"married";"secondary";"no";9374;"yes";"no";"unknown";20;"may";273;1;-1;0;"unknown";"no"
43;"admin.";"married";"secondary";"no";264;"yes";"no";"cellular";17;"apr";113;2;-1;0;"unknown";"no"
36;"technician";"married";"tertiary";"no";1109;"no";"no";"cellular";13;"aug";328;2;-1;0;"unknown";"no"
20;"student";"single";"secondary";"no";502;"no";"no";"cellular";30;"apr";261;1;-1;0;"unknown";"yes"
31;"blue-collar";"married";"secondary";"no";360;"yes";"yes";"cellular";29;"jan";89;1;241;1;"failure";"no"
40;"management";"married";"tertiary";"no";194;"no";"yes";"cellular";29;"aug";189;2;-1;0;"unknown";"no"
56;"technician";"married";"secondary";"no";4073;"no";"no";"cellular";27;"aug";239;5;-1;0;"unknown";"no"
37;"admin.";"single";"tertiary";"no";2317;"yes";"no";"cellular";20;"apr";114;1;152;2;"failure";"no"
25;"blue-collar";"single";"primary";"no";-221;"yes";"no";"unknown";23;"may";250;1;-1;0;"unknown";"no"
31;"services";"married";"secondary";"no";132;"no";"no";"cellular";7;"jul";148;1;152;1;"other";"no"
38;"management";"divorced";"unknown";"no";0;"yes";"no";"cellular";18;"nov";96;2;-1;0;"unknown";"no"
42;"management";"divorced";"tertiary";"no";16;"no";"no";"cellular";19;"nov";140;3;-1;0;"unknown";"no"
44;"services";"single";"secondary";"no";106;"no";"no";"unknown";12;"jun";109;2;-1;0;"unknown";"no"
44;"entrepreneur";"married";"secondary";"no";93;"no";"no";"cellular";7;"jul";125;2;-1;0;"unknown";"no"
26;"housemaid";"married";"tertiary";"no";543;"no";"no";"cellular";30;"jan";169;3;-1;0;"unknown";"no"
41;"management";"married";"tertiary";"no";5883;"no";"no";"cellular";20;"nov";182;2;-1;0;"unknown";"no"
55;"blue-collar";"married";"primary";"no";627;"yes";"no";"unknown";5;"may";247;1;-1;0;"unknown";"no"
67;"retired";"married";"unknown";"no";696;"no";"no";"telephone";17;"aug";119;1;105;2;"failure";"no"
56;"self-employed";"married";"secondary";"no";784;"no";"yes";"cellular";30;"jul";149;2;-1;0;"unknown";"no"
53;"admin.";"married";"secondary";"no";105;"no";"yes";"cellular";21;"aug";74;2;-1;0;"unknown";"no"
68;"retired";"divorced";"secondary";"no";4189;"no";"no";"telephone";14;"jul";897;2;-1;0;"unknown";"yes"
31;"technician";"married";"secondary";"no";171;"no";"no";"cellular";27;"aug";81;3;-1;0;"unknown";"no"
59;"management";"married";"secondary";"no";42;"no";"no";"cellular";21;"nov";40;1;-1;0;"unknown";"no"
32;"management";"single";"tertiary";"no";2536;"yes";"no";"cellular";26;"aug";958;6;-1;0;"unknown";"yes"
49;"technician";"married";"tertiary";"no";1235;"no";"no";"cellular";13;"aug";354;3;-1;0;"unknown";"yes"
42;"admin.";"divorced";"secondary";"no";1811;"yes";"no";"unknown";14;"may";150;1;-1;0;"unknown";"no"
78;"retired";"divorced";"primary";"no";229;"no";"no";"telephone";22;"oct";97;1;-1;0;"unknown";"yes"
32;"blue-collar";"married";"secondary";"no";2089;"yes";"no";"cellular";14;"nov";132;1;-1;0;"unknown";"yes"
33;"management";"married";"secondary";"no";3935;"yes";"no";"cellular";6;"may";765;1;342;2;"failure";"yes"
23;"services";"single";"tertiary";"no";363;"yes";"no";"unknown";30;"may";16;18;-1;0;"unknown";"no"
38;"management";"single";"tertiary";"no";11971;"yes";"no";"unknown";17;"nov";609;2;101;3;"failure";"no"
36;"management";"single";"tertiary";"no";553;"no";"no";"cellular";11;"aug";106;2;-1;0;"unknown";"no"
52;"blue-collar";"married";"secondary";"no";1117;"yes";"no";"cellular";13;"may";365;1;-1;0;"unknown";"no"
32;"technician";"married";"tertiary";"no";396;"yes";"no";"cellular";13;"may";205;3;-1;0;"unknown";"no"
32;"technician";"single";"tertiary";"no";2204;"yes";"no";"cellular";21;"nov";11;4;-1;0;"unknown";"no"
34;"management";"single";"tertiary";"no";872;"yes";"no";"unknown";7;"may";105;2;-1;0;"unknown";"no"
55;"blue-collar";"married";"primary";"no";145;"no";"no";"telephone";2;"feb";59;3;5;2;"other";"no"
26;"blue-collar";"married";"primary";"no";0;"yes";"no";"unknown";21;"may";425;1;-1;0;"unknown";"no"
32;"entrepreneur";"single";"primary";"yes";-849;"yes";"yes";"cellular";4;"feb";204;1;-1;0;"unknown";"no"

Subject: read a csv

From: Eleftheria Paidousi

Date: 13 Dec, 2012 16:04:09

Message: 7 of 7

i'd better like to have a matrix in th end....

for example i may decide that i don't want age and delete them...
or that i don't want all the throw

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