Creating a text file of a list of words that will be inputted by reading file; using readStringUntil(‘\n’).
I can read a single line and store the first word. How can the process be repeated for all lines.
How to save words as the file is read; to be used latter to compare word created in project?
Update 09/03/2022:
Code snippet updated with routine the reads filenames until end of file. How tdo you read, for example the third word of the file?
William
hello,
i find very strange to use word to store (ascii) text reading …
but i work mainly with Microchip PIC … and don’t know all on arduino possibilities.
it is not a good way to do init , inside a loop for
make you init at the beginning of function or as global in your program
String inputTexte[10];
void readTexte()
{
if(LittleFS.exists("/Texte.txt"))
{
// Open a "Texte.txt" for reading
File word = LittleFS.open("Texte.txt", "r"); //input ascii
if (!word)
{
Serial.println("file 'Texte.txt' open failed or No 'Texte.txt' file");
}
else
{
while(Texte.available())
{
for(x=0 ; x < 10; x++) //Build an arrary of words
{
inputTexte[x] = Texte.readStringUntil('\n');
Serial.println(inputTexte[x]);
}
}
}
}
}
Thank you paulfjujo.
Have list of word read from wordfile.txt. Question now is how do I print third word in the list?
Appreciate your input!
William
hello,
did you get all values ?
what is the result of printout ?
can you post or show us your wordfile.txt
are each word delimited by LF in your file ?
usualy separator is ‘,’ or ‘;’ as in CSV file ..
Question now is how do I print third word in the list?
Serial.println(inputTexte[2]);
String table begin at index 0 , so third value is at index 2 ..
Having Pauljujo’s help; function for reading text file line by line is complete:
Thank you Pauljujo!
William