How to remove apostrophes from empty cells when using readtable
Show older comments
I used readtable to import a csv file and any blank cells, including non-blank cells following, are automatically filled with apostrophes or have apostrophes surrounding a value. With the apostrophes surrounding a value I am not able to plot them. I was wondering what the best way is to either completely get rid of the apostrophes (converting to NaN) or how to make it so they only affect blank cells, and not the cells following.

Accepted Answer
More Answers (1)
Image Analyst
on 22 May 2023
0 votes
Why are you trying to plot them? Shouldn't you just use table2array to extract the numbers and plot only the numbers (shown in the lower part of your table)? Also, you forgot to attach your table. In a table, all items in a table column must be of the same type. Since your columns mix numbers and strings, it made everything a string since that is the only type that would work for every item in the column. Maybe you should tell readtable to skip some lines (via the NumHeaderLInes option) in your file to avoid that problem. Then everything would be numbers. Of course we can't try anything because you forgot to attach your data file.
Categories
Find more on Cell Arrays 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!