Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Reading a *.csv file from different points

I have a *.csv file that I would like to read depending on a list of lines
that I have. I was wondering how I can do that. Eg. I want to read line 300,
202, .... can I just jump to the line I want and read it? How can I
accomplish this if I cannot read it from any line?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Reading a *.csv file from different points

On variable length lines, you cannot just "skip around" as you are asking.
However, you could make a routin to simulate this by making small use of the
SEEK command to reset the position back to the top of the file.

private function readaline(hFilePtr as long, intRowNumber as long) as string
dim vLine as variant, iLoop as long

'Move to beginning of file (vastmseek.htm)
Seek hFileptr, 1

iloop=0

do while not eof(hFilePtr)
iloop = iloop + 1
line input #hfielptr, vLine
if iLoop =IntRowNumber
exit do
else
vline="" 'Clear any bad data
end if
loop

readaline=cstr(vLine)

end function


HTH

"WannaBeExceller" wrote in
message ...
I have a *.csv file that I would like to read depending on a list of lines
that I have. I was wondering how I can do that. Eg. I want to read line
300,
202, .... can I just jump to the line I want and read it? How can I
accomplish this if I cannot read it from any line?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Reading a *.csv file from different points

Thank you very much AMDRIT. It worked like magic! Thank you.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
reading from another file and pasting to current file, "combobox" Darius New Users to Excel 1 September 26th 05 07:13 AM
reading data from 2nd file in 1st file using Combobox Darius Excel Programming 0 September 22nd 05 04:51 PM
reading from text file to excel file dgoel Excel Programming 0 April 18th 05 06:49 PM
Reading from ini file Tammy[_4_] Excel Programming 4 February 8th 04 10:11 AM
Reading from file Asif[_3_] Excel Programming 4 November 16th 03 05:28 AM


All times are GMT +1. The time now is 07:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"