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 ?

2 Kommentare

@sushil malani: please click the paperclip button and upload an original data file.
column 1 is what i want to be split.

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

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);

Weitere Antworten (0)

Kategorien

Produkte

Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by