import large csv file

23 ビュー (過去 30 日間)
Cem SARIKAYA
Cem SARIKAYA 2019 年 5 月 10 日
コメント済み: Walter Roberson 2019 年 5 月 13 日
hello, I have a 22 digit count in the first column of my csv file and all the numbers are important. But Matlab has written the number as E21 and losing significant figures, what should I do? and I have more than one question I just want to get the 1st, 3rd and 5th columns, how can I do?

採用された回答

Walter Roberson
Walter Roberson 2019 年 5 月 11 日
You cannot read in the first field as numeric. There is no support in the built in types for 22 decimal digits of precision.
detectImportOptions on the file and set the variable type for the first field to be string and readtable with that options structure.

その他の回答 (2 件)

Arvind Sathyanarayanan
Arvind Sathyanarayanan 2019 年 5 月 10 日
Use the readmatrix() command to import the csv file. The 'Output Type' arugment will let you change the data type and 'Range' argument lets you specify the columuns you want to read.
  3 件のコメント
Cem SARIKAYA
Cem SARIKAYA 2019 年 5 月 10 日
yes I used the readmatrix () command, but what I try is "Undefined function or variable 'readmatrix'." I got the error, and I thought this code couldn't get the csv files.
Arvind Sathyanarayanan
Arvind Sathyanarayanan 2019 年 5 月 10 日
Could you please upload the code you're trying and the csv file?

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


Jeremy Hughes
Jeremy Hughes 2019 年 5 月 13 日
The issue with 22 digits of precision in DECIMAL is that MATLAB's default number type is DOUBLE which really can only handle around 17 digits at which point the number system itself cannot distinguish the numbers. The import functions are rounding to the nearest double value.
i.e.
1.000000000000000000000001 is the same as 1.0
If the data are all integers, you can specify int64/uint64.
>> A = readmatrix(filename,'OutputType','int64')
If not integers, than Walter's answer is the best you can do.
Jeremy
  3 件のコメント
Jeremy Hughes
Jeremy Hughes 2019 年 5 月 13 日
Ahhh yes, you're right.
This makes me curious about where the data comes from. Maybe 80 bit long double?
Walter Roberson
Walter Roberson 2019 年 5 月 13 日
https://en.wikipedia.org/wiki/Extended_precision#IEEE_754_extended_precision_formats x64 architecture uses 64 bit significand with no "hidden bit", so you would not get any integer precision beyond what you could get with uint64.

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

カテゴリ

Help Center および File ExchangeLarge Files and Big Data についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by