Error in string operation

2 visualizaciones (últimos 30 días)
klb
klb el 4 de Jul. de 2020
Comentada: klb el 4 de Jul. de 2020
Runs correctly first time. On second run, says "Error using == Comparison between logical and string is not supported."
What am I not doing right?
% Import file
file = string(extractFileText('my_text.pdf'))
% Break the file into lines
datachunks = splitlines(file)
% Eliminate empty lines
datachunks = datachunks(datachunks == "") % Error here. No change to anything preceeding this line for the second rerun. These 3 lines are literally the first 3 commands.
Thank you for your time in advance.

Respuesta aceptada

Steven Lord
Steven Lord el 4 de Jul. de 2020
My guess is that on a later line of code you overwrite the datachunks variable (which previously contained a string array) with a logical array. If so then the next time you tried to compare it with "" you would receive this error.
>> true == ""
Error using ==
Comparison between logical and string is not supported.
  1 comentario
klb
klb el 4 de Jul. de 2020
Well, ..Its a seveal page long pdf wth text in the header & footer and timevalues in between. I want to eliminate header and footer text. Text in main body contans names of individuals and series of timestamps relevant to each. After elimination I will convert timestamps which are cuurently strings to datetime, and then to seonds. (these are just some sports related runs so using seocnds for close comparison) And then perform required analysis. A bit roundabbout. This code will serve as template code for future imports too. I can always clean up in excel and then bring into MATLAB but I want to keep it all in one application. Plus excel crashes with large datasets.
Ill accpet your answer towards furture reference; might encounter the scenario you indicate. Thanks.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by