Vb.net read file by line and print lines which contain a specific string - vb.net

How would I print out every line from a text file that contains a specific string? I have tried something but that didn't work. Thanks in advance...

Related

How to Print a File without using a streamreader in VB.NET

i want to print files like doc,html,xml,...
all examples that i find are using a streamreader
is there something wich prints my file without reading it and save it in a string?
its thery important for me that its dont saving the text in a string first because the files have different encodings and formatting
ty :D

Finding occuramce of a string in a column in excel based text file

I am using vb.net to find the sum of occuramce of string in a particular column in text file(excel based) . The text file is not tab delimited, and it is separated column by column nicely, I only learnt how to read line by line using stream reader but I have no idea how to read only the last column of the line and summing up the specific string that I want. Any idea how to do it? Not nesseccary nid to provide me the code
If by "an Excel-based text file" you mean that the values are comma-separated, you can read it in line by line, like you already are doing using a stream, and then use Split to separate the line out into an array. Google "vb.net split" to learn how to do this.

VB.NET Append text to the end of a line in an exiting CSV file

How can I append text to the end a line in a text file with lines already there in VB.NET?
For example my text file looks like this:
header1,header2,header3
value1,value2,value3
stuff1,stuff2,stuff3
and I want to add new text to the end of each line so it looks like this:
header1,header2,header3,newheader
value1,value2,value3,newvalue
stuff1,stuff2,stuff3,newstuff
I know that in Perl you can point to the line and then act on it, is there some VB.net way to do this?
If the file isn't too big, the simplest is, probably, to use the IO.File.ReadAllLines method to read the file into memory and modify the data and write it back with the WriteAllLines method.
For very large files you're probably looking at reading each line modifying it and writing it to a different file.

Not completed file reading

I'm trying to print the number of rows in my file training.txt but found out that my code does not read the whole file. Code goes like this:
row = 1
for line in io.lines 'training.txt' do
row = row + 1
end
print(row)
I tried changing the file with test.txt that has the same format with training.txt and file reading worked fine, reads until the end of file. So maybe the problem is with my text file? But how? It has the same format.
Text files are uploaded here for testing.
The file you uploaded training.txt is not the same format as test.txt, it does not have newline characters that indicate the EOL (End of Line). Try opening it in notepad to see the difference.

write new line to file

I'm trying to write to file newline. I'm using WS_DOWNLOAD but have no idea how to write new line into text.
Anyone knows ?
Set a character type field to cl_abap_char_utilities=>cr_lf and insert that in the appropriate places (wherever you want a new line) to your output.
This contains the carriage return & linefeed characters.