ReadLineNumber

Discussion in 'Basic4ppc Wishlist' started by WZSun, Feb 24, 2008.

  1. WZSun

    WZSun Member Licensed User

    Hi,
    I know using SQL is great but it requires the additional SQL components and .NET Framework 2 to work. On some devices, this requires installation of .net framework to be installed which may be cumbersome for end-customers. I also observed that it affects the initial loading time as well.

    Using CSV is the current workaround for me. But this requires using the TABLES control to load the whole chunk of data to it.. and in a way, utilising memory space.

    Is there a way where I can simply retrieve a specific line in a text file (consisting of standard CSV or whatever data strings) without using Tables? I wrote a simple ReadLine sometime back.. but this requires reading all the lines from first line to the 'n' line. This is fast if the number of lines are small. But if it grows bigger, it becomes slower.

    Does anyone has any workaround for this? if not, perhaps can Erel add that into say, v6.06 as it'd be much much faster..


    Rgds
    WZSun
     
    Last edited: Feb 24, 2008
  2. agraham

    agraham Expert Licensed User

    That is the only way of doing it with a CSV file as each line is of unknown length so you need to start at the beginning and count.

    Unlikely to be much/any faster than using FileRead and counting lines yourself as reading a line is a low level .NET stream function.
     
  3. LineCutter

    LineCutter Active Member Licensed User

    You could index the locations of the lines for subsequent revisits, even if you dump the file from memory.

    If the CSV has fixed line sizes then you could calculate the offset quite easily.

    If the CSV has an index variable then you could binary search to it (read from your search point forwards until you reach a CRLF, then read & parse the index variable. Jump whichever way it suggests)
     
  4. WZSun

    WZSun Member Licensed User

    Hi,
    Thanks for all the suggestions. Looks like I have to stick to the CSV for now.

    Meanwhile, I hope Erel can provide some kind of basic db functions without loading them to the tables first.

    Thanks again!
     
Loading...