#1
  1. Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2002
    Posts
    12
    Rep Power
    0

    The Gentle Art of File Data Extraction


    I'm trying to find and extract data from a file with C, but I can't seem to find a good way to do so. I almost thought I had it there with strncmp() for a while, but that road only led to dissapointment.

    Here's what I'm trying to do:
    Given a file like this;

    --start of fake.db--
    Harry$555-3489$Lake Worth
    Peter$555-8230$Paris
    Simone$555-3903$Kiev
    Fred$555-9308$Chile
    Gulliver$555-0376$Paris
    Stephanie$555-0903$Monterrey
    --end of fake.db--

    I want to be able to input a location, a phone number, or a name and return the entire line for my parsing.

    Anyone have any ideas? Perhaps a new function to explore?
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,638
    Rep Power
    4247
    Ever thought of exploring the strstr() function :)
  4. #3
  5. Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2002
    Posts
    12
    Rep Power
    0
    thanks... I looked up some info (http://www.opengroup.org/onlinepubs/...sh/strstr.html) on that function and I'm not sure I see how it can help me...

    perhaps you have deeper examples of how this works?
  6. #4
  7. /(bb|[^b]{2})/

    Join Date
    Nov 2001
    Location
    Somewhere in the great unknown
    Posts
    5,163
    Rep Power
    792
    Code:
    if (strstr(searchstr, filestr) != null)
        //this line contains the data
    else
        //this line does not contain the data
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    0
    Rep Power
    0
    I found a good utility for data extraction. Try this.

    http://www.medullatek.com/mttex.htm

IMN logo majestic logo threadwatch logo seochat tools logo