Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Txt file I/O

Discussion in 'Information Technology' started by pechoi@syr.edu, Jul 28, 2006.

Tags:
  1. pechoi@syr.edu

    pechoi@syr.edu
    Expand Collapse
    Guest

    Hi,
    Is there any way to search then start reading line from search line?
    For instance I have input as:
    Game#1
    Player1 Player2
    Game#2
    Player2 Player3

    Search for Game#2 and start reading file from there.

    THank you,
     
  2. Loading...

    Similar Threads Forum Date
    Sikh News Profiled US Sikh Throws 'Know Me' Challenge Breaking News Jul 25, 2016
    Hard Talk Sikh Musician Racially Profiled At US Restaurant Hard Talk Jul 6, 2016
    India Patna man files defamation suit against son for inter-caste marriage Breaking News Jan 6, 2014
    USA Federal hate crime indictment filed in 'savage' attack on cab driver Breaking News Apr 4, 2013
    Malaysia Bank Islam Files Police Reports Against Chief Economist Breaking News Jan 23, 2013

  3. KARL DEWEY

    KARL DEWEY
    Expand Collapse
    Guest

    You need to normalize your data to look like this --
    GAME PLAY1 PLAY2
    Game#1 Player1 Player2
    Game#2 Player2 Player3

    GAME, PLAY1, and PLAY2 are field names in the table.


    "pechoi@syr.edu" wrote:

    > Hi,
    > Is there any way to search then start reading line from search line?
    > For instance I have input as:
    > Game#1
    > Player1 Player2
    > Game#2
    > Player2 Player3
    >
    > Search for Game#2 and start reading file from there.
    >
    > THank you,
    >
    >
     
  4. Dirk Goldgar

    Dirk Goldgar
    Expand Collapse
    Guest

    <pechoi@syr.edu> wrote in message
    news:1147385219.996200.133230@j73g2000cwa.googlegroups.com
    > Hi,
    > Is there any way to search then start reading line from search line?
    > For instance I have input as:
    > Game#1
    > Player1 Player2
    > Game#2
    > Player2 Player3
    >
    > Search for Game#2 and start reading file from there.


    Not that I can think of. I believe you'll need to open the file, read
    lines in a loop until you come to the one beginning "Game#2", and then
    go on from there.

    --
    Dirk Goldgar, MS Access MVP
    www.datagnostics.com

    (please reply to the newsgroup)
     
  5. Douglas J. Steele

    Douglas J. Steele
    Expand Collapse
    Guest

    "Dirk Goldgar" <dg@NOdataSPAMgnostics.com> wrote in message
    news:%23rjXF7WdGHA.4912@TK2MSFTNGP05.phx.gbl...
    > <pechoi@syr.edu> wrote in message
    > news:1147385219.996200.133230@j73g2000cwa.googlegroups.com
    >> Hi,
    >> Is there any way to search then start reading line from search line?
    >> For instance I have input as:
    >> Game#1
    >> Player1 Player2
    >> Game#2
    >> Player2 Player3
    >>
    >> Search for Game#2 and start reading file from there.

    >
    > Not that I can think of. I believe you'll need to open the file, read
    > lines in a loop until you come to the one beginning "Game#2", and then
    > go on from there.


    Depending on how big the file is, you could read the entire file into a
    variable, and then manipulate the variable.


    Dim intFreeFile As Integer
    Dim lngFileSize As Long
    Dim strBuffer As String
    Dim strFileToRead As String

    lngFileSize = FileLen(strFileToRead)
    strBuffer = Space(lngFileSize)

    intFreeFile = FreeFile
    Open strFileToRead For Binary As intFreeFile
    Get #intFreeFile, , strBuffer
    Close intFreeFile


    Don't forget that the string will now include all of the carriage
    return/line feed characters now: you'll have to handle them yourself.

    --
    Doug Steele, Microsoft Access MVP
    http://I.Am/DougSteele
    (no private e-mails, please)
     
  6. Dirk Goldgar

    Dirk Goldgar
    Expand Collapse
    Guest

    "Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in
    message news:%23b0gJuadGHA.3996@TK2MSFTNGP04.phx.gbl
    >
    > Depending on how big the file is, you could read the entire file into
    > a variable, and then manipulate the variable.


    True, but if subsequent processing is going to be line-oriented, I think
    it's easier just to read it line by line.

    --
    Dirk Goldgar, MS Access MVP
    www.datagnostics.com

    (please reply to the newsgroup)
     
  7. Douglas J. Steele

    Douglas J. Steele
    Expand Collapse
    Guest

    "Dirk Goldgar" <dg@NOdataSPAMgnostics.com> wrote in message
    news:uWYFjvcdGHA.1320@TK2MSFTNGP04.phx.gbl...
    > "Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in
    > message news:%23b0gJuadGHA.3996@TK2MSFTNGP04.phx.gbl
    >>
    >> Depending on how big the file is, you could read the entire file into
    >> a variable, and then manipulate the variable.

    >
    > True, but if subsequent processing is going to be line-oriented, I think
    > it's easier just to read it line by line.


    Put it in an array:

    Split(strBuffer, vbCrLf)

    I think it'll be faster when it's in memory than reading the file line by
    line.

    --
    Doug Steele, Microsoft Access MVP
    http://I.Am/DougSteele
    (no private e-mails, please)
     

Share This Page