l*b 发帖数: 4369 | 1 会用matlab的话,可以用csvread后面加参数:
csvread(filename, row, column, range) |
|
t*****e 发帖数: 2228 | 2 多谢,还是不行
>> M = dlmread('def.dat', '', 5, 2);
Error using dlmread (line 141)
Mismatch between file and format string.
Trouble reading number from file (row 1u, field 14u) ==> 我数据里有几列是字
符串
M = csvread('def.dat', 5, 2);
Error using dlmread (line 141)
Number of HeaderColumns is greater than number of columns in file.
Error in csvread (line 50)
m=dlmread(filename, ',', r, c);
不知道错哪里了.
还有一个更重要的问题. 我的主要任务是把一个sas project 在matlab里实现,把sas
data读入matlab只是第一步. sas里用的是proc genmod link = logit etc 那我
matl... 阅读全帖 |
|
m***c 发帖数: 202 | 3 转存为CSV,再用CSVREAD读是最快的办法,如果只有几个文件的话。 |
|
s*****c 发帖数: 753 | 4 fprintf? 读?
Have you tried fscanf with %f? How about csvread or dlmread?
If you really was reading it in as a string (assume it is stored in A) and
then parsing the string to get the value, can't you parse A(1:end-1)? |
|
p*******9 发帖数: 801 | 5 while ~feof(fid)
tline = fgetl(fid);
fprintf(fid_tmp, '%s\n', tline);
end
fclose(fid_tmp);
fclose(fid);
finalfile = csvread('temp.csv');
好像还是不工作 |
|
p*******9 发帖数: 801 | 6 while ~feof(fid)
tline = fgetl(fid);
fprintf(fid_tmp, '%s\n', tline);
end
fclose(fid_tmp);
fclose(fid);
finalfile = csvread('temp.csv');
好像还是不工作 |
|
s****1 发帖数: 1519 | 7 s = fread(fid, 'char');
s = char(s');
s = s(1:end-1);
fprintf(fid_temp, '%s',s);
finalfile = csvread('temp.csv');
应该可以了 fopen, fclose啥的你就自己写了 |
|
s*****c 发帖数: 753 | 8 fprintf? 读?
Have you tried fscanf with %f? How about csvread or dlmread?
If you really was reading it in as a string (assume it is stored in A) and
then parsing the string to get the value, can't you parse A(1:end-1)? |
|
p*******9 发帖数: 801 | 9 while ~feof(fid)
tline = fgetl(fid);
fprintf(fid_tmp, '%s\n', tline);
end
fclose(fid_tmp);
fclose(fid);
finalfile = csvread('temp.csv');
好像还是不工作 |
|
p*******9 发帖数: 801 | 10 while ~feof(fid)
tline = fgetl(fid);
fprintf(fid_tmp, '%s\n', tline);
end
fclose(fid_tmp);
fclose(fid);
finalfile = csvread('temp.csv');
好像还是不工作 |
|
s****1 发帖数: 1519 | 11 s = fread(fid, 'char');
s = char(s');
s = s(1:end-1);
fprintf(fid_temp, '%s',s);
finalfile = csvread('temp.csv');
应该可以了 fopen, fclose啥的你就自己写了 |
|
t*****e 发帖数: 2228 | 12 想了很多办法都没成功.
网上搜索到sasread.m还有demo,可是怎么也没有运行成人家的demo,只好放弃.
还有的办法是sas export 成csv或者txt file, 我的SAS文件有158万行,12列,export后
其实也就82Mb样子,matlab读应该没问题,可是用csvread 或者load 或者txtread 都有
错误:
Error using load
Unknown text on line number 1 of ASCII file .......
我的文件第一行就是各个variable名,都是character,下面都是数据,有number, 有char
,不知道怎么读进来.
唯一成功的是xlsread,可是只能读进去6w多行,我的版本太低?excel就只能容下6万多行
. 怎么办呢? 现在能想到的本办法就是把sas文件切成25个小文件,每个小文件都差不多
6万多行,然后依次读进matlab再combine.请问大牛有啥建议的?
还有看到一个办法是通过sql server,完全不懂sql,没有仔细看的说.
谢谢! |
|
u*****3 发帖数: 796 | 13 csvread/dlmread 指定从第二行开始读。
char |
|