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
Stephen RoesnerAnalysisAsked:
Who is Participating?
 
PatHartmanCommented:
If the file is formatted as a "list" (with or without headers), you can use TransferText to link to it and work with it as if it were a table.  The only time you would need to use the input method is if the file were a non-standard format such as a transaction file used in EDI (Electronic Data Interchange) where companies used very complex but standardized record formats.  Each "record" is a completely different format from other records.  So it might require reading 20 individual records of different "types" and putting them all together to get the name and address of a client.
0
 
Rey Obrero (Capricorn1)Commented:
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
0
 
Stephen RoesnerAnalysisAuthor Commented:
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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.