How can i convert multiples lines into 1 text string (big block)
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
so my file is like:
abcdef
abcdef
abcdef
abcdef
and i would like them to be in 1 text string without enters: 'abcdefabcdefabcdefabcdef'
0 Kommentare
Antworten (2)
Stephen23
am 22 Apr. 2016
Bearbeitet: Stephen23
am 22 Apr. 2016
To remove all whitespaces within the text:
str = regexprep(fileread('temp.txt'),'\s+','')
Or to only remove newlines and carriage return characters:
str = regexprep(fileread('temp.txt'),'[\n\r]+','')
I tested these on this file:
0 Kommentare
J. Webster
am 22 Apr. 2016
file = textread('text.txt', '%s', 'whitespace','');
file will be a cell array containing the string you want.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Characters and Strings finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!