Link to home
Start Free TrialLog in
Avatar of Tacobell777
Tacobell777

asked on

Read part of file...

I need some VB code to read only part of a file, it's been a while since I worked with VB but I know it can be done, just don't know how anymore.

Example, I know the last time I imported a file it was 77,600 kb upon current import I know the file is 78,777 kb so I know I only want to read the difference ie. 1,177 kb

How to read the 1,177 kb last part of a file in VB?

FYI: I will be using this in a DTS package.

Then how to loop over this 1,177 kb of data within the DTS package? I need to do the following comparison for each line

IF LEFT(currentRow, 3) IS "***"
Then do something here
otherwise
Just import the row.
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

You can use the seek functin to move the file pointer once the file is open.

Seek #1, 77600

Idle_Mind
Avatar of Tacobell777
Tacobell777

ASKER

That means I need to read the whole 80 Mb or in some cases 300 Mb...
'seek' will get u to the position u want. So u wont have to read the whole 80Mb or so as u say.
After doing a seek, jus read in the rest of the file.
Would any code samples be possible? Maybe I did not make it clear, but I am no VB programmer, I used it for a little while and now I need to use it in a DTS package...
ASKER CERTIFIED SOLUTION
Avatar of CD-Softy
CD-Softy

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Guys,

I have been trying and trying but none of these scripts work within a MS SQL DTS package....
It looks as if the syntax needs to be different...
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I did post this in the MS SQL Server area, but nothing at all there. At least here I am getting somewhere ;-))

What your saying sounds interesting...... but....
How to do that? I mean I worked with DTS before and created connections to text files but have not seenw hat you are refering to, unless you mean "Skip rows"? If so, how do I know which row I last imported?
Ya, I was talking about skip rows.  You could write the last row imported to a text file (ini file) and then use the dynamic properties task to read it and update your "skip rows" property.

Also, sounds like the Microsoft Text file driver could be a good option.  I'd set it up with the format of your file and try it.

Sorry didn't see your original post in SQL Server group....

Brett
You deleted your question in the SQL group--how long did you leave it open???
I did not get what I was after (which could have been my own fault, not asking the question in the right category) I split the points up anyway.

thanks
You could follow up on the above suggestions and note that you didn't get what you wanted.  We can't read minds and know you're not getting what you want....