Reading numeric values from csv file

조회 수: 41 (최근 30일)
Lola
Lola 2022년 6월 7일
댓글: Lola 2022년 6월 11일
Hi there. I am trying to read numeric values on matlab from a csv file that is created using PuTTY. I want to read data in realtime from row 5 going onwards and column 3 specifically. The data is being captured in realtime. I have tried a using a matlab code but I can't seem to read in the numeric values. I also want to store the values displayed into an array for later use. Please kindly assist
  댓글 수: 5
Lola
Lola 2022년 6월 8일
Yes I'm not sure why the cells are getting mixed up. The reason I'm using PuTTY is because for now I'm reading sensor values from I2C connections. However the aim will be to read data from the receiving end of an nRF24l01 module. So I'm not able to read from a specific pin on arduino.
Walter Roberson
Walter Roberson 2022년 6월 8일
csvread can skip text header lines, and it can skip a fixed number of columns that can include text. But all entries after that on the line must be purely numeric. The only values that csvread would be able to handle in that file are the BPM (all of which happen to be 0 in the sample)

댓글을 달려면 로그인하십시오.

채택된 답변

Chaitan Divagi
Chaitan Divagi 2022년 6월 8일
Hello Lola,
I understand that you want to read the numeric values from specific column from the csv file in realtime.
You can perform this task using MATLAB functions in the following manner:
data = readtable('<CSV-file>.csv','NumHeaderLines',5); % use readtable instead of csvread and 'NumHeaderLines', 5 skips the 5 rows from the table
col_vec = data(:, 3); % reads the 3rd colum from the table and stores in the col_vec variable
I hope that the information provided helps in resolving your query.
Thanks,
Chaitan,
  댓글 수: 3
Walter Roberson
Walter Roberson 2022년 6월 10일
data = readtable('<CSV-file>.csv','NumHeaderLines',5); % use readtable instead of csvread and 'NumHeaderLines', 5 skips the 5 rows from the table
col_vec = data{:, 3} ; % reads the 3rd colum from the table and stores in the col_vec variable
Lola
Lola 2022년 6월 11일
Thank you that works perfectly

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by