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 ?

2 comentarios

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

Iniciar sesión para comentar.

 Respuesta aceptada

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

Más respuestas (0)

Categorías

Más información sobre Data Import from MATLAB en Centro de ayuda y File Exchange.

Productos

Versión

R2023a

Etiquetas

Preguntada:

el 20 de Abr. de 2023

Comentada:

el 21 de Abr. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by