Link to home
Start Free TrialLog in
Avatar of Stephen Roesner
Stephen RoesnerFlag for United States of America

asked on

How do I search a specific space in a text file for specific data

I use the following code to open a super large text file
so I can rewrite it to a smaller size for import.
This code works great.

Now I have another even larger text file that I need data from
I have determined that if I can say something like
(only grab the records where col 92-93-94-95 = 2014)
and write it to file 2 then I can narrow it down to the records I need
is this possible?


 'this converts the large file to an Access importable file
    Open "C:\ERPDP\NationsIn\LISLEPD\EFTOFS5617MONMEMDD150201T1620042.txt" For Input As #1
    Open "C:\ERPDP\MONMEMD.txt" For Output As #2
    Do Until EOF(1)
        Line Input #1, str
        If str & "" <> "" Then _
        Print #2, Left(str, 406)
    Loop
    Close
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

try this


   Open "C:\ERPDP\NationsIn\LISLEPD\EFTOFS5617MONMEMDD150201T1620042.txt" For Input As #1
   dim strFind as string
   strFind="2014"
    Open "C:\ERPDP\MONMEMD.txt" For Output As #2
    Do Until EOF(1)
        Line Input #1, str
        If Instr(str,strFind) Then
                  
        Print #2, Left(str, 406)
        end if
    Loop
    Close
ASKER CERTIFIED SOLUTION
Avatar of PatHartman
PatHartman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Stephen Roesner

ASKER

wow never dawned on me to link since I never needed to do it in the past - great solution - I can link to it do what I want with it and it doesn't add an ounce to the db - great idea, simple but great. I do feel stupid LOL.
thank you.