reading a csv file

hi,
I have a csv file as I shared the link with you. I am going to read my file but I don't how
please someone help me to read my file. first my file contained the rownamesa and colnames that i removed manually.
<https://drive.google.com/file/d/0BwOX04QQkaXTZHJLbmtWakdIMGc/view?usp=sharing my file address>
thank you

Answers (1)

Star Strider
Star Strider on 14 Jan 2016

1 vote

I get an error when I try to access that link. Attach your file to your Question here using the ‘paperclip’ icon, and be sure to complete both the ‘Choose file’ and ‘Attach file’ steps.
Depending on the way your file is formatted and what it contains, use either the csvread or xlsread functions. Another option is the textscan function.

4 Comments

sorry its too big to be uploaded i tried both csvread and textscan but i cant figur out what to do i tried all below >> mat = importdata('corr.dat', ','); Error using importdata (line 136) Unable to open file.
>> mat = csvread('corr.csv', ','); Error using csvread (line 35) File not found.
>> filename = 'corr.dat'; >> M = csvread(filename) Error using csvread (line 35) File not found.
>> pwd
ans =
/usr/data/nfs6/izadi/mat/rlog
>> filename = 'corrr.dat'; >> M = csvread(filename) Error using csvread (line 35) File not found.
>> untitled Error using dlmread (line 139) Mismatch between file and format string. Trouble reading number from file (row 1u, field 2u) ==> ;0.319335956589281;0.627299380797565;0.265862377744763;0.617875082474954;0.59904987140894;0.393628679584718;0.0318334082815229;0.252868681625569;0.146618670135157;0.291260339674982;0.139964249106137;0
Error in csvread (line 48) m=dlmread(filename, ',', r, c);
Error in untitled (line 1) mat = csvread('corrr.csv');
>> filename = 'corrr.csv'; >> M = csvread(filename) Error using dlmread (line 139) Mismatch between file and format string. Trouble reading number from file (row 1u, field 2u) ==> ;0.319335956589281;0.627299380797565;0.265862377744763;0.617875082474954;0.59904987140894;0.393628679584718;0.0318334082815229;0.252868681625569;0.146618670135157;0.291260339674982;0.139964249106137;0
Error in csvread (line 48) m=dlmread(filename, ',', r, c);
>>
It seems not comma-delimited. If the lines that appear in your Comment are the actual data in the file, the delimiter is a semicolon (;).
If it has only numeric data, see if dlmread will work with it:
data = dlmread(filename, ';');
If you know how many columns of data there are in the file and what they contain (strings, floating-point, etc., number of header lines) I can write a textscan call that could work. Without the file itself (or a representative sample of it), that’s the best I can do.
thank you
My pleasure.

Sign in to comment.

Tags

Asked:

on 14 Jan 2016

Edited:

on 15 Jan 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!