Computing.Net > Forums > Programming > read file line by line

read file line by line

Reply to Message Icon

Original Message
Name: genet
Date: February 16, 2007 at 05:25:44 Pacific
Subject: read file line by line
OS: xp
CPU/Ram: intel 3.6 ghz
Comment:

hey again!

thx for the help at my last post!
want to ask if there is some way i can read a .txt file line by line ignoring lines beginning with "::" then writing the lines back into a file but without the lines with 2 colons at the beginning. i saw something like this i think using for /f tokens.. thx!


Report Offensive Message For Removal


Response Number 1
Name: Fist (by fmwap)
Date: February 16, 2007 at 05:43:08 Pacific
Reply: (edit)

I dunno about using "for" to do this, but in *nix it's a simple grep command:

grep -Ev "^::" bah

I would recommend getting GNU grep for win32. It's over here:
http://unxutils.sourceforge.net/


Report Offensive Follow Up For Removal

Response Number 2
Name: genet
Date: February 16, 2007 at 05:44:28 Pacific
Reply: (edit)

o sorry i forgot to say i need this in dos batch..

thx


Report Offensive Follow Up For Removal

Response Number 3
Name: IVO
Date: February 16, 2007 at 06:08:13 Pacific
Reply: (edit)

FindStr /B /V "::" FileName > FileOut


Report Offensive Follow Up For Removal

Response Number 4
Name: genet
Date: February 16, 2007 at 11:06:54 Pacific
Reply: (edit)

thx! works fine.. sorry for the late reply


Report Offensive Follow Up For Removal

Response Number 5
Name: Mechanix2Go
Date: February 17, 2007 at 00:18:27 Pacific
Reply: (edit)

Works in NT. For DOS you'll need a 16 bit regex, like grep.


=====================================
If at first you don't succeed, you're about average.

M2



Report Offensive Follow Up For Removal


Response Number 6
Name: genet
Date: February 17, 2007 at 01:05:51 Pacific
Reply: (edit)

hey again thx!

I am still trying to read a file line by line so i can for axemble read the first line echo it, then the second line ect ect ect until EOF: While doing this i want it to exclude lines that begin with ::

sry i ask so much from you all.. but i really do try my best befor asking.

thx again.


Report Offensive Follow Up For Removal

Response Number 7
Name: Mechanix2Go
Date: February 17, 2007 at 01:12:54 Pacific
Reply: (edit)

FindStr /B /V "::" < FileName


=====================================
If at first you don't succeed, you're about average.

M2



Report Offensive Follow Up For Removal






Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: read file line by line

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 5 Days.
Discuss in The Lounge