Splitting Excel column input into 5 at FIXED WIDTH columns

I have data in excel column of format BANKNIFTY03JUN2127800PE.NFO which i want to split at fixed width like - Column 1 : BANKNIFTY, COlumn 2 with date : 03JUN21, COlumn 3 with strike price: 27,800, column 4: PE COlumn5:.NFO. How do i do it ?

 采纳的回答

filename = 'AppropriateFileName.xlsx';
AppropriateColumnNumber = 7; %change to actual column number
opts = detectImportOptions(filename);
opts = setvartype(opts, AppropriateColumnNumber, 'string');
T = readtable(filename, opts);
TC = T{:,AppropriateColumnNumber};
%comment out any entries you do not need the output for
BANKNIFTY = extractBetween(TC, 1, 9);
date = datetime(extractBetween(TC, 10, 16), 'InputFormat', 'ddMMyy');
strike_price = double(extractBetween(TC, 17, 21));
PE = extractBetween(TC, 22, 23);
NFO = extractBetween(TC, 24, 27);

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Data Import from MATLAB 的更多信息

产品

版本

R2023a

标签

Community Treasure Hunt

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

Start Hunting!

Translated by