How to import data from a csv that contains strings numbers and blank cells

I have a csv that contains a single column with a lot of data in it. The data is a variety of strings, numbers and blanks, where I want to keep it in the exact order including all of the blank cells. So an example of the data would be:
A
05
G
12
I have tried to use importdata and this works perfectly, the problem is my csv has over 1 million rows and for some reason using importdata only imports to just over the first 100k rows.
Any help would be appreciated!

5 件のコメント

Roberto Herrera-Lara
Roberto Herrera-Lara 2015 年 4 月 14 日
do you have any error? or message?
Roberto Herrera-Lara
Roberto Herrera-Lara 2015 年 4 月 14 日
how much ram do you have?
R2
R2 2015 年 4 月 14 日
I do not get any kind of message or erros and have 8 GB of ram
Philip Caplan
Philip Caplan 2015 年 4 月 15 日
Have you tried using "csvread" to import the entire column? For some examples, please see:
R2
R2 2015 年 4 月 16 日
csvread does not work as it only accepts numerical values, as I have text in the column as well as numbers I get an error message.

サインインしてコメントする。

 採用された回答

Star Strider
Star Strider 2015 年 4 月 16 日
I would experiment with textscan.
Example:
fidi = fopen('filename.csv');
D = textscan(fidi, '%s', 'Delimiter',',');
fclose(fidi);
This should read everything in as a cell array of strings. (I don’t have your file, so this is just a guess on my part. I will leave it to you to experiment.) You may need other arguments in the textscan call (such as 'EndOfLine'), but it may work as described here without any changes.

2 件のコメント

R2
R2 2015 年 4 月 19 日
I changed the delimiter to \n to include all of the blank spaces, but otherwise this worked! Thanks for your help!
Star Strider
Star Strider 2015 年 4 月 19 日
My pleasure!

サインインしてコメントする。

その他の回答 (1 件)

Roberto Herrera-Lara
Roberto Herrera-Lara 2015 年 4 月 14 日

0 投票

100k rows, and if you do the same process several times(10 times) and then you concatenate the matrixs, i dont know, perhaps works!! =) Divide and conquer algorithm

タグ

質問済み:

R2
2015 年 4 月 13 日

コメント済み:

2015 年 4 月 19 日

Community Treasure Hunt

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

Start Hunting!

Translated by