Importing csv file with scientific notation

7 ビュー (過去 30 日間)
Adolf Krige
Adolf Krige 2019 年 7 月 23 日
コメント済み: Adolf Krige 2019 年 7 月 23 日
I am having a lot of trouble importing my csv files, I have tried: importdata, dlmread and textscan. Just cant seem to get it working.
I have 100+ files, so changing them manually is tricky
when using importdata the result end up as a cell aray: {' - 6 . 5 9 9 4 8 E - 0 0 1 , - 4 . 8 6 2 2 6 E + 0 0 4 , - 6 . 5 9 9 4 8 E - 0 0 1 , 3 . 8 2 3 7 5 E + 0 0....'}
  1 件のコメント
Guillaume
Guillaume 2019 年 7 月 23 日
The main problem with your file is that it is encoded in UTF-16LE (16-bit unicode little endian), which matlab doesn't officially support for reading and writing.
Is there any chance that you can change the settings of whichever software is writing these files so that it is written with a different encoding (UTF8 would be a lot better)?

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

採用された回答

Guillaume
Guillaume 2019 年 7 月 23 日
編集済み: Guillaume 2019 年 7 月 23 日
Unfortunately, none of the high-level functions work with UTF16, so you have to go low-level. Even then, you'll get a warning that the encoding is not supported. As of R2019a, I'm not aware of instances where it's not decoded properly, but: here be dragons. If you can change the setting of your exporting tool.
fid = fopen('test.csv', 'rt', 'n', 'UTF16LE'); %Issues a warning that UTF16 is not supported
data = textscan(fid, repmat('%f', 1, 12), 'Delimiter', ',', 'HeaderLines', 6); %Same warning again
data = [data{:}]
fclose(fid);
  1 件のコメント
Adolf Krige
Adolf Krige 2019 年 7 月 23 日
Thanks a lot, I was hoping that I was just doing something stupid.
I checked and the software has no options that I can see, it also unfortunately does not help with all the data that I already have.
It does work, however, despite the complaints.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeText Files についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by