My Assistant
![]() ![]() |
|
|
Mar 19 2007, 11:27 AM
Post
#1
|
|
|
UtterAccess Addict Posts: 142 |
Hello all,
I have the following file that i'm trying to create an import spec for it: HDRIWSDDA17032007 111111111|16032007|4585.52 222222222|16032007|0.00 333333333|16032007|17860.88 TRLIWSDDA17032007 How can i remove the header and trailer for this file in an import spec? i just need the information in between the header and footer. Thank you. |
|
|
|
Mar 19 2007, 11:55 AM
Post
#2
|
|
|
UtterAccess VIP Posts: 2,331 From: West Michigan |
Unfortunately, you can't create an import spec to do that. I generally use low-level IO to import the text file. I have several examples on my website (see sig below) that illustrate this. "ImportLineInput.mdb" is one such.
Another thing you could do is run code to remove the header and footer and then import it through the wizard. Something like this: CODE Sub CleanFile(DirtyFile As String, CleanFile As String) And call it like this:
Dim MyString As String Dim i As Integer Open DirtyFile For Input As #1 Open CleanFile For Output As #2 Do While Not EOF(1) Line Input #1, MyString 'Output the line Record If InStr(MyString, "|") > 0 Then Print #2, MyString End If Loop ' Close text file. MsgBox "Done!" Close #1 Close #2 End Sub CODE Function RunCleanFiles() This will read each line and only output the lines that have your delimiter ("|") in it.
Call CleanFile("C:\DirtyLineInput.txt", "C:\LineInput.txt") End Function Edited by: Roger_Carlson on Mon Mar 19 12:58:33 EDT 2007. Edited by: Roger_Carlson on Mon Mar 19 12:59:21 EDT 2007. |
|
|
|
Mar 19 2007, 11:57 AM
Post
#3
|
|
|
Retired Moderator Posts: 8,589 From: Lansing, MI |
Using an import spec I know of no way to ignore it. I have cases where I get records I don't need. In this case I let the bad record import and then I have an automated delete after import. This works as long as it is always recognizable. Yours look like this would work.
HTH Ken |
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 21st May 2013 - 01:11 AM |