Working in international team causes problems reading csv files
3 views (last 30 days)
Show older comments
Renger van Nieuwkoop
on 2 Jun 2018
Edited: Walter Roberson
on 7 Jun 2018
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
0 Comments
Accepted Answer
Nayan Rao
on 5 Jun 2018
Edited: Walter Roberson
on 7 Jun 2018
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 Comments
Walter Roberson
on 5 Jun 2018
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
More Answers (0)
See Also
Categories
Find more on Get Started with MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!