How can I remove double quotes from a string?

42 ビュー (過去 30 日間)
Heidi Hirsh
Heidi Hirsh 2018 年 12 月 10 日
コメント済み: Walter Roberson 2020 年 7 月 17 日
I am reading in data from a .csv file using textread. The data looks like this:
"Date","Time","Temperature"
"2018-06-02","14:45:24","23.5942"
"2018-06-02","14:46:24","24.6013"
"2018-06-02","14:47:24","24.5911"
"2018-06-02","14:48:24","24.8547"
I can read in date, time, and temperature as strings but then I am left with the values in double quotes. Is there a way to read the values in some other way so I that I am left withouth the data in double quotes?

回答 (2 件)

Mark Thomson
Mark Thomson 2020 年 7 月 17 日
Hi, I found readtable.m a bit slow.
You can also try this:
strs={'"Hi there"','"Joe"'} % Example cell array of strings with "..."
regexp(strs,'[^""]*','match','once')
I borrowed the regexp syntax from:
https://de.mathworks.com/matlabcentral/answers/399532-recovering-text-between-parentheses-using-regexp#answer_319061
  1 件のコメント
Walter Roberson
Walter Roberson 2020 年 7 月 17 日
[^""] is any one character that is not either " or " -- in other words it is the same [^"]

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


Sean de Wolski
Sean de Wolski 2018 年 12 月 10 日
Use readtable.

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by