S
SBinVA
Here's the challenge:
I have a request to be able to import a Standard Interchange Format
(.sif) file into an Access database on demand. The file layout is
standard ASCII text and is fairly simple, but I can't seem to wrap my
head around this one since it's not a normal request of me.
The file looks like this when opened in a text viewer:
PN=xxxx
PD=yyyy
P%=zzzz
PN=aaaa
PD=bbbb
P%=cccc
Then the cycle repeats. (I left out the majority of the "fields" to
save space since there are about 27.)
I need to pull this into a table somewhat like this:
PN PD P%
xxxx yyyy zzzz
aaaa bbbb cccc
All of the "column" identifiers are 2 letters followed by the equal
sign and are consistent from file to file
I'm looking to write some code that I can use to parse the file after
the user has designated it's location and read it into a temp table in
the database or even a recordset or array. After that's done I'll loop
through the records and extract the data I need and write it to the
necessary tables.
I'm assuming the code will need to read the file then find the first
instance of "PN=" and write whatever is between "PN=" and the end of
line code to column 1 of the temp table / recordset / array and then do
the same for the next identifier and so on until it reaches "PN=" the
next time. At this point it should go to the next record and begin
writing the values to the next record and continuing until it reaches
EOF.
The logic seems pretty sound but I'm just not sure about how to
accomplish this in VBA. Any ideas?
I have a request to be able to import a Standard Interchange Format
(.sif) file into an Access database on demand. The file layout is
standard ASCII text and is fairly simple, but I can't seem to wrap my
head around this one since it's not a normal request of me.
The file looks like this when opened in a text viewer:
PN=xxxx
PD=yyyy
P%=zzzz
PN=aaaa
PD=bbbb
P%=cccc
Then the cycle repeats. (I left out the majority of the "fields" to
save space since there are about 27.)
I need to pull this into a table somewhat like this:
PN PD P%
xxxx yyyy zzzz
aaaa bbbb cccc
All of the "column" identifiers are 2 letters followed by the equal
sign and are consistent from file to file
I'm looking to write some code that I can use to parse the file after
the user has designated it's location and read it into a temp table in
the database or even a recordset or array. After that's done I'll loop
through the records and extract the data I need and write it to the
necessary tables.
I'm assuming the code will need to read the file then find the first
instance of "PN=" and write whatever is between "PN=" and the end of
line code to column 1 of the temp table / recordset / array and then do
the same for the next identifier and so on until it reaches "PN=" the
next time. At this point it should go to the next record and begin
writing the values to the next record and continuing until it reaches
EOF.
The logic seems pretty sound but I'm just not sure about how to
accomplish this in VBA. Any ideas?