Loading a .csv file that contains units
20 views (last 30 days)
Show older comments
Hey guys. I need to load multiple .csv files into my code where I am interested in the data of one column (the dBm value). However, the numbers there also have units, not seperated by a comma. Is there a way to get rid of the units, or load the numbers without them? Thank you very much in advance!
0 Comments
Answers (2)
Star Strider
on 17 Jun 2022
Try something like this —
opts = detectImportOptions('CSV File Test 2022 06 17.txt');
opts = setvartype(opts, 'Var4','double');
opts = setvaropts(opts, 'Var4','Suffixes','dBm');
T1 = readtable('CSV File Test 2022 06 17.txt', opts)
Here, ‘Var1’ is a duration array, ‘Var2’ and ‘Var3’ are character arrays, and ‘Var4’ is set as a double array. Setting its suffix to 'dBm' removes the suffix, leaving a double value. See Remove Prefix or Suffix Characters From Variables (it took me a while to find it).
I created ‘SV File Test 2022 06 17.txt’ to test this.
.
0 Comments
See Also
Categories
Find more on Logical 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!