![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
| I have a bunch of text files I'm trying to parse. The files all have several occurrences of chr(26), which is EOF (End Of File). Each file is ~ 1meg of text, and every file is a real mess. The looks something like this: Date=1/1/04-=time4:20pmSalesperson-=-)JIM HENDERSON$%L_#*(%-+* da_FIRST.........------MIKE da_LAST .........------TURCO da_PRODUCT.....------BOAT da_YY...........------04 )(#$%^&* Date=1/1/04-=time4:20pmSalesperson-=-)JIM HENDERSON$%L_#*(%-+*--= da_FIRST.........------JAMES da_LAST .........------THAMES da_PRODUCT.....------RV da_YY...........------02 )(#$%^&* Note that this is pseudo data (for simplicity) and also that I am using the * character to represent the EOF character. Also, if I do a manual search-and-replace for the EOF character, my code works perfectly. What is happening, for sure, is that Access Basic is seeing the EOF character and interpreting it as an actual end of file. Here is a code snippet: Do While Not EOF(FileNo) Input #FileNo, g$ Select Case left(g$, 4) Case "da_F" .AddNew If Len(g$) > 53 Then ![RO CLOSE] = Right(g$, Len(g$) - 53) End If Case "da_L" If Len(g$) > 53 Then ![RO-NUMBER] = Right(g$, Len(g$) - 53) End If So, the problem I have is how to either ignore or get rid of this EOF character. I've tried Line Input, Input # and Input functions. In every case, when I hit the EOF char, Access thinks it is the end of the file. If you have any suggestions, I'd appreciate it. Here's another issue, which I guess is a little OT because its a windows problem, but it still relates to this database. Doing a search-and-replace for this EOF character in notepad is (marginally) acceptable for now. On some XP computers, using notepad, I see this EOF character as a right facing arrow and its easy to find, search out and replace. On other computers, control characters are displayed as a box. I don't think its a Unicode problem because I'm able to see all of the higher characters on the screen. Its just the lower (control) characters that display on some computers and not on others. FWIW, I have tried different fonts on the different computers. Both fixedsys and courier fonts display the character correctly on my computer, but as boxes on other computers. Is there a control panel setting somewhere, or something, that turns the display of control characters on or off? I'm using AccessXP. Thanks! Mike |
#3
| |||
| |||
|
|
Mike: This will work: Public Function TEOF() Dim rline, newline As String Dim eof As String Dim fs, r Set fs = CreateObject("Scripting.FileSystemObject") Set r = fs.OpenTextFile("d:\alexdata\eof.txt", 1, 0) eof = Chr(26) Do While r.AtEndOfStream <> True rline = r.readline Debug.Print rline newline = Replace(rline, eof, "") Debug.Print newline eloop: Loop endit: r.Close End Function In this case all eof chars in the input line are removed and not replaced by anthything. You could replace with a space or anything else. This uses the FileSystemObject. It is in some ways more powerful than the older method. Good Luck Ira Solomon |
![]() |
| Thread Tools | |
| Display Modes | |
| |