Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. sponsors. rss.
 From: Phillip Davies
  Where is Phillip Davies?
 TRURO
 United Kingdom
 Phillip Davies
 To: Cetin Basoz
  Where is Cetin Basoz?
 Izmir
 Turkey
 Cetin Basoz
 Tags
Subject: RE: CSV file read
Thread ID: 233900 Message ID: 233903 # Views: 24 # Ratings: 0
Version: Visual FoxPro 9 Category: Projects and Design
Date: Tuesday, July 07, 2009 9:59:12 PM         
   


> > I have a CSV file which I open with fopen()
> >
> > 2 things to ponder
> >
> > 1.
> > the csv file is permanently been written to by 3rd party
> >
> > I want to read the latest line of information -- in a loop
> > ok with loop, but get the last line I can't see how
> >
> > how do i do that?
> >
> > 2.
> >
> > I use FREAD() FSEEK(), but can't start at last line?
> > also lines are variable bytes length
> >
> > is FREAD() FSEEK() best way
> >
> >
> > Many Thanks if helping
> >
> > Phillipe
>
> You can use lowlevel as you do. Try using fgets() instead of fread() so you can loop line wise. There are alternatives which I prefer. If the text file is not very large:
> 1) FileToStr("myFile.csv") reads the file in a string variable and you could get the lines using alines() or memlines().
> 2) You could create a cursor and do an "append from type delimited" - or csv but delimited is preferable.
> Both operate very fast. If your csv file would invariably conain some data per line that you can differentiate (ie: in csv you get something like orderNo, productId whatever that may serve as a row identifier) then you could use a "for" clause with "append from" and directly get the line(s) you need.
>
> The best strategy depends on file content, size etc.
>
> Cetin Basoz
>
> .Net has got better.Think about moving - check my blog:
> Blog (main)
> Blog (mirror)



Thanks for that

ok I will try fgets(), but how to get record pointer to last line is my problem
not sure how to do this
i can move to end of file, but not start of last line to read in (n) bytes for example
Phillipe



COMPLETE THREAD
CSV file read Posted by Phillip Davies @ 7/7/2009 8:51:53 PM
RE: CSV file read Posted by Cetin Basoz @ 7/7/2009 9:28:52 PM
RE: CSV file read Posted by Phillip Davies @ 7/7/2009 9:59:12 PM
RE: CSV file read Posted by Cetin Basoz @ 7/7/2009 10:28:30 PM
RE: CSV file read Posted by Phillip Davies @ 7/7/2009 11:13:29 PM