Working in international team causes problems reading csv files

1 回表示 (過去 30 日間)
Renger van Nieuwkoop
Renger van Nieuwkoop 2018 年 6 月 2 日
編集済み: Walter Roberson 2018 年 6 月 7 日
Hi We are an international team of Matlab users working on a project. Every user has its own notebook, some with European, some with American local settings. Reading csv-files using xlsread is causing problems, as the formatting of figures is different. Is there another fast way of reading csv-files with numbers and strings without running in this problem? The solution as proposed in this forum of adjusting the region settings is a no-go-option. Thanks Renger

採用された回答

Nayan Rao
Nayan Rao 2018 年 6 月 5 日
編集済み: Walter Roberson 2018 年 6 月 7 日
As seen in the folwoing link 'xlsread' only supports 7-bit ASCII in xlsx files https://www.mathworks.com/help/matlab/ref/xlsread.html#btjfnq9-7 and hence the discrepancy! As a work around you can use the 'textscan' function in MATLAB- https://www.mathworks.com/help/matlab/ref/textscan.html?searchHighlight=textscan&s_tid=doc_srchtitle
I believe this should solve the issue. Let me know if you face any issues.
  2 件のコメント
Walter Roberson
Walter Roberson 2018 年 6 月 5 日
Note that if you plan to use textscan() with functions that use characters beyond 255, then you should probably pass in the UTF encoding as a parameter to fopen().
See https://www.mathworks.com/matlabcentral/answers/270857-how-to-read-16-bit-text-with-matlab#answer_211879 which includes a reference to code I posted to detect UTF encoding.
See also https://www.mathworks.com/matlabcentral/answers/285186-importing-data-without-knowing-number-of-columns#comment_368710 where I posted code that uses this together with knowledge of what release supports what facility in order to read in UTF-encoded csv files and do a smart conversion to table form.
That said...
My interpretation was that the problem was likely to do with the fact that some countries use comma as the decimal point; and that datetime() can only handle limited forms of named month abbreviations and only if passed the right locale that was used in constructing the names of the months (which requires the user or code to know that information.) datetime() cannot, for example, handle using Mär or Mrz as a month name (German) see https://www.mathworks.com/matlabcentral/answers/98832-why-does-datenum-give-me-an-error-message-when-i-pass-german-date-strings-as-input-arguments-in-matl
Renger van Nieuwkoop
Renger van Nieuwkoop 2018 年 6 月 7 日
Dear Nayan and Walter
Thanks for the fast and detailed reply!
Renger

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

タグ

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by