D
dash
Thanks a lot John,
Yeah It is going to be a regular job, I would prefer to do it using
VBA.
Could you be please be more specific about the Access - VBA coding
part, as its been some time I have done something in it.
I would really appreciate if you can write the code for me (how to
write the recordsets)
Thanks a lot
Dash
Dash,
If this is a one-off task, I'd use text file tools to split the file
into three simple files, one for each table, that can be imported in
the
usual way. Assuming that the input file is laid out like this:
Table1 Record1
Table2 Record1
Table3 Record1
Table1 Record2
Table2 Record2
Table2 Record2
...
I'd use Perl from the Windows command prompt, substituting the actual
names and paths of the files you want.
perl -ne"print if ($. % 3) == 1" INPUT.txt > TABLE1.txt
perl -ne"print if ($. % 3) == 2" INPUT.txt > TABLE2.txt
perl -ne"print if ($. % 3) == 0" INPUT.txt > TABLE3.txt
Perl uses $. for the line number of the input, so
$. % 3
is "line number modulo 3", which cycles 1,2,0,1,2,0 from the first line
on. If Perl isn't installed on your computer you can download it free
from www.activestate.com
It's possible to write code to do the same thing in just about any
other
programming or scripting language. If this import was going to be a
regular task, I'd do it differently, writing Access VBA code that opens
three recordsets, one for each table, and then reads the file a line at
a time. The first line would be parsed and appended to the first table,
then the second and third to their tables, and then back to line 4 and
the first table again.
Yeah It is going to be a regular job, I would prefer to do it using
VBA.
Could you be please be more specific about the Access - VBA coding
part, as its been some time I have done something in it.
I would really appreciate if you can write the code for me (how to
write the recordsets)
Thanks a lot
Dash
Dash,
If this is a one-off task, I'd use text file tools to split the file
into three simple files, one for each table, that can be imported in
the
usual way. Assuming that the input file is laid out like this:
Table1 Record1
Table2 Record1
Table3 Record1
Table1 Record2
Table2 Record2
Table2 Record2
...
I'd use Perl from the Windows command prompt, substituting the actual
names and paths of the files you want.
perl -ne"print if ($. % 3) == 1" INPUT.txt > TABLE1.txt
perl -ne"print if ($. % 3) == 2" INPUT.txt > TABLE2.txt
perl -ne"print if ($. % 3) == 0" INPUT.txt > TABLE3.txt
Perl uses $. for the line number of the input, so
$. % 3
is "line number modulo 3", which cycles 1,2,0,1,2,0 from the first line
on. If Perl isn't installed on your computer you can download it free
from www.activestate.com
It's possible to write code to do the same thing in just about any
other
programming or scripting language. If this import was going to be a
regular task, I'd do it differently, writing Access VBA code that opens
three recordsets, one for each table, and then reads the file a line at
a time. The first line would be parsed and appended to the first table,
then the second and third to their tables, and then back to line 4 and
the first table again.