Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Any suggestions on how to write the best text-finding code (takes a given text and searches all files in provided folder for that string of text and outputs which files contain the text, as well as the location of the text within the file)?

1 Ansicht (letzte 30 Tage)
I have a folder full of text files, and I want the code to go through each file and search for a specified 5 character text (like abcde). If the 5 characters are there (in that order, like a word) then I want the code to tell me if the abcde is there and on which line. The code should then print out the 10 letters before this abcde and the 10 letters after the abcde. What is the best way to do this? It is for a protein sequence

Antworten (1)

Sid Jhaveri
Sid Jhaveri am 7 Dez. 2016
You can refer to the links given below for information regrading the functions that that might be helpful in achieving you goal: https://www.mathworks.com/help/matlab/ref/contains.html
Basically, your code should:
1) Know which files are present in the directory and which files you would like to scan.
2) Read those files.
3) Check if the file contains the sequence.
Implementation of above steps can vary. But, I believe this information will be a good starting point for you.

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by