Re: Importing data into a table
- From: Tim Ferguson <FergusonTG@xxxxxxxxxxxx>
- Date: Sat, 11 Mar 2006 16:19:01 -0800
=?Utf-8?B?Q2hyaXM=?= <Chris@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
news:9055A0B5-F5E7-4740-AA01-75F511F570CE@xxxxxxxxxxxxx:
Can some one help so when I import the text file those rows will be
deleted
Use Open and Line Input# to filter the original text file into a temp
file?
I am totaly new to this can you help rewrite the code so it will do
what you are saying and I will try it
This is air code and without looking up any of the functions:
' obvious
const pathToMyFile as String = "\\newyork\data\mydata.txt
const pathToTempFile as string = "c:\temp\christemp.txt"
' need to recognise when the good data is finished and the
' three final lines are starting
const firstBadLine as string = "Total number of records"
' file handles
dim inFile as integer
dim outFile as integer
' obtain legal handles
inFile = freefile()
outFile = freefile()
' open the files: this needs to be error-trapped properly
open pathToMyFile for input as #inFile
open pathToTempFile for output as #outFile
' skip over first four lines
dim i as integer
dim readText as string
for i = 0 to 3
' read in the line but don't do anything with it
line input #inFile, readText
next i
' copy all the next lines into the temp file
do while not eof(#inFile)
' read in the next line
line input #inFile, readText
' examine it to see if it's the first illegal one
' you may be able to think of a more robust test, but
' I don't know your data as well as you do
if left(readText, len(firstBadLine)) = firstBadLine Then
exit do
end if
' since it's a valid line, copy it out to the
' new temp file
print #outFile, readText
' now go round again for the next line
loop
' tidy up
close #inFile
close #outFile
That should give you enough of a clue to carry on with. Hope it helps
Tim F
.
- Follow-Ups:
- Re: Importing data into a table
- From: John Nurick
- Re: Importing data into a table
- References:
- Re: Importing data into a table
- From: Tim Ferguson
- Re: Importing data into a table
- Prev by Date: Re: Shell function
- Next by Date: Re: Shell function
- Previous by thread: Re: Importing data into a table
- Next by thread: Re: Importing data into a table
- Index(es):
Relevant Pages
|