Filter Repeated Data

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • virtualweb
    New Member
    • Aug 2007
    • 30

    Filter Repeated Data

    Hi..

    Im saving States and Cityies from people answering a poll in a flat file database delimited by pipes. Flat file named States_Cities.t xt

    The information is saved in this format:

    FLORIDA|MIAMI
    FLORIDA|JACKSON VILLE
    FLORIDA|TAMPA
    TEXAS|HOUSTON
    TEXAS|DALLAS
    TEXAS|AMARILLO
    TEXAS|AUSTIN
    TEXAS|MCALLEN
    TEXAS|WACO
    ILLINOIS|CHICAG O

    I need a snippet of code which will read this file and then tell me how many different states I got, which are them, and which cities belong to each.

    Thanx
    Regards from virtualweb
  • numberwhun
    Recognized Expert Moderator Specialist
    • May 2007
    • 3467

    #2
    Well, what have you tried thus far? We can certainly help you troubleshoot your existing code, but a code writing service this is not, sorry. Post what you have tried and we can help you.

    Regards,

    Jeff

    Comment

    • miller
      Recognized Expert Top Contributor
      • Oct 2006
      • 1086

      #3
      Welcome to TSDN,

      What you're attempting to do is not hard. The simplest method would be to simply load your file data into a hash of arrays where the keys are the state names. Actually, since you're looking for uniqueness, a hash of hashes would be better, where the final value would be a count.

      To learn about complex data structures, look here.To learn a new technique for checking uniqueness, look here:- Miller

      Comment

      Working...