Loading a .csv file that contains units

14 Ansichten (letzte 30 Tage)
Paul
Paul am 17 Jun. 2022
Beantwortet: Star Strider am 17 Jun. 2022
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!

Antworten (2)

KSSV
KSSV am 17 Jun. 2022
Read about readtable

Star Strider
Star Strider am 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)
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.
.

Produkte


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by