1 Replies - 455 Views - Last Post: 06 February 2013 - 03:12 PM Rate Topic: -----

#1 sepelama   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 30-October 11

Search for words and change format

Posted 06 February 2013 - 03:06 PM

So basically i have a file with a lot of names and ages and other unnecessary stuff with this kind of format:

Name: Example
Age: 20
Hobbies: Blahblah
Other stuff: jashdjahsdj

And i want to grab the name and the age of every single person in the file and reformat it to something like this:


I'm really new to this so any help would be appreciated.

Thanks in advanced :rolleyes:

Is This A Good Question/Topic? 0
  • +

Replies To: Search for words and change format

#2 modi123_1   User is online

  • Suitor #2
  • member icon

Reputation: 14097
  • View blog
  • Posts: 56,497
  • Joined: 12-June 08

Re: Search for words and change format

Posted 06 February 2013 - 03:12 PM

It should be a pretty simple use of streamreader and streamwriter.

Using stream reader open up the file for your source.. in a while loop read each line.. if it starts with name then use the string namespace's "substring" to get the value.. store that in a temp variable.. and then look for 'age'.. do the same sort of substring to get that value.. then use streamwriter to append those two values into another file.

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1