Loading a .csv file that contains units

18 次查看(过去 30 天)
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!

回答(2 个)

KSSV
KSSV 2022-6-17
Read about readtable

Star Strider
Star Strider 2022-6-17
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)
T1 = 2×4 table
Var1 Var2 Var3 Var4 ________ _____________ __________ ____ 02:14:37 {'Max. RSSI'} {'normal'} -59 02:14:38 {'Max. RSSI'} {'normal'} -57
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.
.

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by