有字符csv文件导入matlab,将大量CSV文件导入Matlab

I have a CSV file 1.6 GB large, that I need to feed into matlab. I will have to do this frequently and I need it to run quickly. The file is of the form:

20111205 00:00.2 99.18 6 E

20111205 00:00.2 99.18 5 E

20111205 00:00.2 99.18 1 E

20111205 00:00.2 99.195 5 E

20111205 00:00.2 99.195 5 E

20111205 01:27.0 99.19 5 E

20111205 02:01.4 99.185 1 E

20111205 02:01.4 99.185 1 E

20111205 02:01.4 99.185 1 E

20111205 02:01.4 99.185 1 E

The code I have right now is the following:

tic;

format long g

fid = fopen('C:\Program Files\MATLAB\R2013a\EDU13.csv','r');

[c] = fscanf(fid, '%d,%d:%d.%d,%f,%d,%c');

c = reshape(c, 7, length(c)/7)

toc;

But this is far too slow. I would appreciate a method of getting this CSV file into matlab in the most efficient manner possible. Thank you!

解决方案

Consider using a binary file format. Binary files are much smaller and don't need to be converted by MATLAB into the binary format. Hence they are much faster to read and write. They may also be more accurate (precision may be higher).

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值