readinf specific line of the file? how to?
Moderator: General Moderators
readinf specific line of the file? how to?
Hi,
Ok if i have opened the text file that has lines of data in it I want to search line by line if i have line let say containing "hello world" if I do hahe such line I want to be able to delte that line.
How can I do that?
Thanks for help!
Ok if i have opened the text file that has lines of data in it I want to search line by line if i have line let say containing "hello world" if I do hahe such line I want to be able to delte that line.
How can I do that?
Thanks for help!
But none of those are reading file lines they read bytes, ... I can try to get contect of the file and the do foreach (hmm thats a VB) well separate the string by `/n` and then look (some how ) if one of the parts have my "hellow word" if yes then remove that array alemnt (some how) and write new srting back o file...
Hmm... i have no idea what im doing today... swithcing languages does hurt.
Hmm... i have no idea what im doing today... swithcing languages does hurt.
yes i saw that, still dont see any wat to get lines... like for example if i do bash script for linux i would yse grep to get the line wthat contain my "Hello World". Basicaly if i have whis line "abc Hello Worl abc" and i do grep 'Helo World' I would get returned the full line... thats what im looking for
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
If the file you are loading is relatively small, I would use file() to load it into an array and loop using a foreach(), checking your match using if() and substr()
If the file is large use feyd's suggestion, and apply that comparison the same way.
As for feyd's suggestion, what are you having problems with? There are plenty examples for looping through file contents.
If the file is large use feyd's suggestion, and apply that comparison the same way.
As for feyd's suggestion, what are you having problems with? There are plenty examples for looping through file contents.