Error when reading a csv using csvread

2 ビュー (過去 30 日間)
Louise Wilson
Louise Wilson 2019 年 10 月 2 日
コメント済み: Louise Wilson 2019 年 10 月 10 日
I am trying to read in a .csv file, which I have read in previously with no trouble.
Here are my command and errors:
>> A=csvread('Tawharanui5278_PSD_1sHammingWindow_50%Overlap_output.csv');
Error using dlmread (line 147)
Mismatch between file and format character vector.
Trouble reading 'Numeric' field from file (row number 394, field number 62257) ==>
...
Error in csvread (line 48)
m=dlmread(filename, ',', r, c);
Any ideas what the problem is? I think the error suggests the problem is with the command rather than the file?
Thanks for your help.

採用された回答

Walter Roberson
Walter Roberson 2019 年 10 月 2 日
Row number 394 of the file is missing field number 62257
You should switch to using readtable() or readmatrix()
  11 件のコメント
Walter Roberson
Walter Roberson 2019 年 10 月 2 日
I suggest you try my detect_UTF_encoding utility that I have attached.
function [encoding, fileclass, file_description, bytes_per_char, BOM_size, byte2char, are_you_sure] = detect_UTF_encoding(FILENAME, allow_warning)
%detect_UTF_encoding determines which UTF encoding has been used for a
%file, and returns:
% * an encoding name;
% * 'no file' or 'file exists'
% * text description of the kind of file it is
% * number of bytes per character;
% * size of the Byte Order Mark used in the file;
% * a handle to a routine that converts byte vectors to characters taking into account
% byte swapping;
% * a flag indicating certainty of that the output is correct
% allow_warning can be set to false for automated use instead of
% interactive use
Louise Wilson
Louise Wilson 2019 年 10 月 10 日
Hi Walter, thanks for the code. Before I tried it, I re-copied and pasted my files using TERACOPY! This has fixed the problem so must have been bad ctrl+c and ctrl+p problem...

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStandard File Formats についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by