[1]Posted by
Kujtim on 3 Jun 2005 08:29 AM[/1]
When we speak about word, should have in mind the formatting of data, different characters used to note actions and symbols. In the other hand we cannot determine structure from it's content i.e. from name, last name etc. But if suppose the resume is in .txt format (or even in .doc) the first line contains name and surname separated by spce chars, the second address, the third city state zip then simply we just read it line by line and use space character as separator.
Let the resume file resume.txt be
George Michael
Wallstreet 11/1A
London England 11000
111-111-111
.....
the code for reading and parsing the file is:
...
using System.Text.RegularExpressions;
...
private void Parse()
{
FileStream fs= new FileStream("resume.txt", FileMode.Open , FileAccess.Read);
StreamReader sr= new StreamReader(fs);
int row=0;
while(sr.Peek()>0)
{
string st = sr.ReadLine();
row++;
switch(row)
{
case 1:
Regex Spliter=new Regex(@" ");
string[] NameSurname = Spliter.Split(st);
txtName.Text = NameSurname[0];
txtSurname.Text = NameSurname[1];
break;
case 2:
txtAddress.Text = st;
break;
case 3:
Regex Spliter=new Regex(@" ");
string[] CityStateZip = Spliter.Split(st);
txtCity.Text = CityStateZip[0];
txtState.Text = CityStateZip[1];
txtZip.Text = CityStateZip[2];
break;
}
}
sr.Close() ;
fs.Close() ;
}
...
because the names of the cities, states can consist of muliple parts you should separate them by comma "," in our case London, England, 11000. In addition change the Regex Spliter=new Regex(@" "); with Regex Spliter=new Regex(@","); in case 3 block.
Enter your message below
Sign in or Join us (it's free).