Results 1 to 6 of 6
  1. #1
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496

    Parse text file

    I want to parse through a text file - each fourth line there tends to be an email which I would like to divide (maybe into an array) to feed it into a row in a table

    so email:john@john.com would be the last line and then it would create a new row.




    I could use the return line to detect the end of the email too.

    what functions would I use and what loops?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Are you positive email will always be on 4th line?

    Every fourth line:

    For i = 1 to 4
    If i = 4 Then
    'parse the line and save to table
    End If
    'get next line
    Next
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by June7 View Post
    Are you positive email will always be on 4th line?

    Every fourth line:

    For i = 1 to 4
    If i = 4 Then
    'parse the line and save to table
    End If
    'get next line
    Next
    Skipping the original quest now as I have converted the source which was a html page of div's, converted them to table tags and then imported them to excel (and in turn Access.

    My next problem is along the same situation though. It's not separate rows - it's one long string, all the data is line after line - no columns or something I can parse using a regular parse editor.

    I have memo fields on each record - I want to split up each memo field into a new table of rows and use text fields instead (of 255)

    so I will have to cycle through each record memo, stuff it into a string, make a record in the new table (probably using a left() function of 255), remove it from the string after it is added, repeat the process until the string is empty (while at the same time stuffing the ID of each record belonging to the memo into the new table).

    then after that move to the next record and memo field. I keep getting corrupted database records because we use a memo field - hence I want to do all this.

    In the future when someone enters text on the record they will be creating a new record in the new table on the form (and I will time stamp and date stamp each new entry).
    I can't get my head around as to how to chop a string up as I go.

    hoping you can help.

  4. #4
    recyan's Avatar
    recyan is offline Expert
    Windows 2K Access 2000
    Join Date
    Dec 2011
    Posts
    662
    Do not know the situation at your end. All the same,
    Long time back, had to do something similar.
    I directly copied ( select required portion on the web page & copy-paste) the HTML page ( not the source ) in to Excel & then I could find a pattern for manipulation & getting the required emailID's.

    Edit : Is this a one time operation or will the database have to get this operation done on an automated basis regularly?

    Thanks

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    I recommend you supply a sample of
    a)some existing records
    b)the same data in the desired output format.

  6. #6
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Something along the lines of

    Code:
    dim strNewRow as string, strMemo as string
    dim lngMemoLength as long
    
    do until fieldXYZ= ""
    
    for i = 0  in strNewrow do 
    
    strNewRpw = left(strMemo,255)
    strMemo = Mid(strMemo, len(strMemo) - len(strnewrpw), len(strMemo))
    'insert new row and push strMemo to field
    
    next
    loop
    where it continues to chop the string down to 0 text and making rows with every 255 characters

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 6
    Last Post: 11-08-2013, 11:18 AM
  2. Replies: 2
    Last Post: 12-27-2012, 09:37 AM
  3. Replies: 3
    Last Post: 07-30-2012, 02:16 PM
  4. Function to Dynamically Parse Text
    By avandalay in forum Access
    Replies: 2
    Last Post: 07-27-2011, 04:07 PM
  5. Parse a File from a Directory and write data to table
    By galahad in forum Database Design
    Replies: 0
    Last Post: 04-23-2009, 08:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums