problems parsing text file...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Martin_SBT
    Forum Member
    • Jun 2002
    • 173

    problems parsing text file...

    Guys

    geezzz i cant get that simple thing to work!!

    I got a text file and i want to extract specific information from it. I tried couple of different approach (texte file to table then table to string then string.find action.... and so on) but cant get that to work. Below is pasted a sample of the text file. What i want to do is each time i find a line that contains "LoginName = {" then i went to extract the line next to that one (ex: _vs = "ECON-APOGEEHALL\\SIEMENS\000") up to the end of the file. the goal will be to take all the extracted lines to populate a listbox. But if you can help me out with the first part of extracting the needed lines, i should be fine for the rest!

    Thanks in advance for any help you can give me!

    sample text file starts here:
    -----------------------------------------------------------------------------------
    %scopeNames = {
    }
    Origin = 1
    FirstGraphicName = {
    _vs = "H-HALL.DYN.HALL\000"
    }
    Initials = {
    _vs = "srd\000"
    }
    Language = 1033
    LoginName = {
    _vs = "PHYSICAL_******\\srdube\000"
    }
    OperatorName = {
    _vs = "Steve Ranger Dub\351\000"
    }
    Preference = 1
    m_schedulerAccessSlidingWindow = 0
    m_usePreferredAccessGroups = 0
    m_supervisor = 0
    FunctionalAccess = {
    [0] {
    DataType = 1
    Level = 3
    }
    [1] {
    DataType = 2
    Level = 1
    }
    [2] {
    DataType = 20
    Level = 1
    }
    [3] {
    DataType = 3
    Level = 2
    }
    [4] {
    DataType = 21
    Level = 1
    }
    [5] {
    DataType = 17
    Level = 1
    }
    [6] {
    DataType = 5
    Level = 1
    }
    [7] {
    DataType = 11
    Level = 1
    }
    [8] {
    DataType = 14
    Level = 2
    }
    [9] {
    DataType = 4
    Level = 1
    }
    [10] {
    DataType = 7
    Level = 1
    }
    [11] {
    DataType = 6
    Level = 1
    }
    [12] {
    DataType = 23
    Level = 1
    }
    [13] {
    DataType = 8
    Level = 1
    }
    [14] {
    DataType = 9
    Level = 1
    }
    [15] {
    DataType = 18
    Level = 1
    }
    [16] {
    DataType = 16
    Level = 1
    }
    [17] {
    DataType = 12
    Level = 1
    }
    [18] {
    DataType = 10
    Level = 1
    }
    }
    bi-assoc INSIGHT_ACCESS_CONFIGURE = {
    #37-4-1-9
    #37-4-1-11
    }
    }

    #37-3-2-37 = {
    %class = "*/ATOMInsightAccount%1"
    %versioningMode = oocNoVers
    %scopeNames = {
    }
    Origin = 1
    FirstGraphicName = {
    _vs = "H-HALL.DYN.HALL\000"
    }
    Initials = {
    _vs = "SBTT\000"
    }
    Language = 1033
    LoginName = {
    _vs = "ECON-APOGEEHALL\\SIEMENS\000"
    -------------------------------------------------------------------------------
  • Stefan_M
    Indigo Rose Customer
    • Nov 2003
    • 315

    #2
    A little help

    Stefan
    Attached Files
    "With a rubber duck, one's never alone."

    Douglas Adams, The Hitchhiker's Guide to the Galaxy

    Comment

    • Martin_SBT
      Forum Member
      • Jun 2002
      • 173

      #3
      Stefan

      I dont know what to say man!

      Thank you so much! the scripting language seem lot easier for you than it is for me. Hope i will be as confortable as you and others are with it. I will try to read your code and catch the trick! i tried it and it works like a champ but i want to learn! eh eh.

      Hope i will be able to return you the favor one day!


      Thanks a zillion times

      Martin

      Comment

      • Stefan_M
        Indigo Rose Customer
        • Nov 2003
        • 315

        #4
        Remarks

        -- set File to parse
        ParseFile="Siemens.txt"
        -- set folder that holds the file to parse
        ParseFolder=_SourceFolder.."\\Autoplay\\Docs\\"
        -- text to search for
        ParseText="LoginName"


        -- read file into table
        ParseTable = TextFile.ReadToTable(ParseFolder..ParseFile);
        -- get the the total number of items in the table.
        TableLines = Table.Count(ParseTable);

        -- run through all table items
        for count = 1, TableLines do
        -- search for "ParseText" in ervery line of hte Table
        if (String.Find(ParseTable[count], ParseText, 1, false))~=(-1) then
        -- if the the string is found -> decrement counter "count" to go to the next line of the table
        count=count+1;
        -- this line holds the string you want
        -- add the tableline to the listbox
        result = ListBox.AddItem("ListBox1", ParseTable[count], "");
        end
        end

        Hope it helps to understand
        Stefan
        "With a rubber duck, one's never alone."

        Douglas Adams, The Hitchhiker's Guide to the Galaxy

        Comment

        Working...
        X