Loading a .csv file that contains units

18 ビュー (過去 30 日間)
Paul
Paul 2022 年 6 月 17 日
回答済み: Star Strider 2022 年 6 月 17 日
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 Center および File ExchangeLogical についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by