Results 1 to 5 of 5

Thread: Finding a character number in a text file

  1. #1 Finding a character number in a text file 
    Forum Cosmic Wizard icewendigo's Avatar
    Join Date
    Jun 2006
    Does anyone know a text editor with a character number search (in addition to the typical line number search) ?

    Im look for character number 504676 in a large file and dont feel like counting to over half a million :x

    thanks :-D

    Reply With Quote  


  3. #2  
    Forum Freshman
    Join Date
    Oct 2008
    Well first of all I am just curious why you would be looking for an individual character in a huge text file. I'm not sure of any that will let you pick out a character but what you could do is use Word or a program like it which has a character counter then just delete from the end until the counter is at the number you want. You can then use the undo function to return the file to its original state.


    Reply With Quote  

  4. #3  
    Forum Sophomore
    Join Date
    Mar 2009
    Or you can write a simple script, and use such wonderful commands as seek and get.

    "Those that would give up essential liberty to obtain a little temporary
    safety deserve neither liberty nor safety."

    -Benjamin Franklin, An Historical Review of Pennsilvanya, 1759
    Reply With Quote  

  5. #4  
    Forum Freshman DrNesbit's Avatar
    Join Date
    Nov 2009
    Supermegatopian Labs
    Write a small program/script in whatever language you know.

    For example in python it would be

    text = file("bigfile.txt").read()
    print text[504676]
    Reply With Quote  

  6. #5  
    Forum Sophomore CShark's Avatar
    Join Date
    May 2008
    East Coast of Canada
    As you don't say what language you are working in, I will go with a pseudo-code example:

    - get the length of the text file (make sure its a least as long as the offset you want -to check)

    - open and read the text file into a buffer

    - use your search number as the offset to return the character at that offset

    char c = Str.GetAt(offset);

    close file, ta-da
    Reply With Quote  

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts