468,321 Members | 1,832 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,321 developers. It's quick & easy.

Parse Text from a .txt file

I need to import text from a text.txt file. The file separates records
by an #.
Below are 2 sample records they are all fixed size. Any help would be
great.
Each line represents a field, but of course there may not be anything
for that field.

#
60
11/26/04
Fri
001215446
JDOE
35
Finance

K

Nothing found
13 CVC 001
25.00
50.00


1abc234
CA
01/01
1234
1234
Gold
Unknown
Type 3
Notes1
notes2
01
11/27/04
#
60
11/26/04
Fri
001215446
JDOE
35
Finance

K

Nothing found
13 CVC 001
25.00
50.00
Somthing Found
12 CVC 000
50.00
55.00
1abc234
CA
01/01
1234
1234
Gold
Unknown
Type 3
Notes1
notes2
11/28/04
Nov 13 '05 #1
3 6922
What is it that you need help with? Is all the information to be stored in
fields in a single table? How "good" is the information -- are there missing
fields whose line in the input is also missing, here and there? Please
clarify and perhaps someone can be of assistance.

Larry Linson
Microsoft Access MVP
"Josh Armstrong" <jo***********@socal.rr.com> wrote in message
news:b6**************************@posting.google.c om...
I need to import text from a text.txt file. The file separates records
by an #.
Below are 2 sample records they are all fixed size. Any help would be
great.
Each line represents a field, but of course there may not be anything
for that field.

#
60
11/26/04
Fri
001215446
JDOE
35
Finance

K

Nothing found
13 CVC 001
25.00
50.00


1abc234
CA
01/01
1234
1234
Gold
Unknown
Type 3
Notes1
notes2
01
11/27/04
#
60
11/26/04
Fri
001215446
JDOE
35
Finance

K

Nothing found
13 CVC 001
25.00
50.00
Somthing Found
12 CVC 000
50.00
55.00
1abc234
CA
01/01
1234
1234
Gold
Unknown
Type 3
Notes1
notes2
11/28/04

Nov 13 '05 #2
I need Access to read the file line by line and enter each line to a
field in one record. Each record is stated with an "#" which
indicates the start of the new record. I can't figure out how to make
Access import it. If it was comma it would be easy but this is not
and I can not change the output.

The blank lines are fields as well, the record just does not have
anything in that field so it is blank.
"Larry Linson" <bo*****@localhost.not> wrote in message news:<78Qpd.401$xk5.172@trnddc09>...
What is it that you need help with? Is all the information to be stored in
fields in a single table? How "good" is the information -- are there missing
fields whose line in the input is also missing, here and there? Please
clarify and perhaps someone can be of assistance.

Larry Linson
Microsoft Access MVP
"Josh Armstrong" <jo***********@socal.rr.com> wrote in message
news:b6**************************@posting.google.c om...
I need to import text from a text.txt file. The file separates records
by an #.
Below are 2 sample records they are all fixed size. Any help would be
great.
Each line represents a field, but of course there may not be anything
for that field.

#
60
11/26/04
Fri
001215446
JDOE
35
Finance

K

Nothing found
13 CVC 001
25.00
50.00


1abc234
CA
01/01
1234
1234
Gold
Unknown
Type 3
Notes1
notes2
01
11/27/04
#
60
11/26/04
Fri
001215446
JDOE
35
Finance

K

Nothing found
13 CVC 001
25.00
50.00
Somthing Found
12 CVC 000
50.00
55.00
1abc234
CA
01/01
1234
1234
Gold
Unknown
Type 3
Notes1
notes2
11/28/04

Nov 13 '05 #3
Josh,
If each field is on a separate line, and you know the expected
type, and you know the ordinal position of the data fields, then you
should be in good shape. The following code snipped should get you
started.

Hank Reed

Dim handle%
Dim strLine As String, strFileName as string

handle = FreeFile
strFileName = "FileName.txt"

Open strFileName For Input As handle

' Find the beginning of the data
strLine =""
While (strLine <> "#")
Line Input #handle, strLine
Wend
Now read text file
While Not (EOF(handle))

Line Input #handle, strLine
If ( IsDate(strLine)) then
Do something
End If
If ( IsNumeric(strLine)) then
Do something
End If
Wend
Close handle
Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by chuck amadi | last post: by
23 posts views Thread by Charles Law | last post: by
22 posts views Thread by Ram Laxman | last post: by
5 posts views Thread by liming | last post: by
AdrianH
1 post views Thread by AdrianH | last post: by
6 posts views Thread by =?Utf-8?B?RGF2aWRN?= | last post: by
1 post views Thread by howard w | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.