Message Boards Message Boards

0
|
2777 Views
|
3 Replies
|
2 Total Likes
View groups...
Share
Share this post:

How to replace quotation mark " from a string?

Posted 3 years ago

Hi there, I have a very odd problem. I am trying to import a txt file that contains biological data. At first, the data is a string, but ultimately (as there are species names and branch lengths for a species tree), I want to manipulate the file such that the species names are strings and the branch lengths are numbers.

I am making good progress; it is rather obvious how to split the file etc. But now I noticed that the biologist has entered some special symbols as part of the species names, e.g. / but also ' and ". The symbol / can easily be mistaken for a division when I use ToExpression, so I will just delete it. I can also delete ' if needed.

But: I simply don't know how to delete the " symbol.

"StringReplace[string,"""->" "] does NOT work.

How can I replace the symbol " by blanks in a string?

POSTED BY: copito411
3 Replies
Posted 3 years ago

Crossposted here.

POSTED BY: Rohit Namjoshi
Posted 3 years ago

Hi copito411,

The embedded " has to be escaped.

StringReplace[string, "\"" -> " "]

However, based on the description, that may not be the best solution. Can you attach a sample file to your question?

POSTED BY: Rohit Namjoshi
Posted 3 years ago

Thanks! It’s so easy! Yes, this works. Thanks so much!

POSTED BY: copito411
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract