Results 1 to 5 of 5

Thread: Reading a text file divided by tab

  1. #1
    Join Date
    Sep 2012
    Posts
    19

    Reading a text file divided by tab

    I have many notepad files with important data in it. The data is arranged such that there is a tab between the various fields. Just to demonstrate the formation of data, let me show you how it is,
    word [tab] word [tab] word [tab] word [tab] word
    word [tab] word [tab] word [tab] word [tab] word
    word [tab] word [tab] word [tab] word [tab] word and so on.
    I now want to accumulate the data in continuous form from these notepad files. So I want to make a code that will check for these tabs that were pressed and remove them to give me continuous data. Can someone help me?

  2. #2
    Join Date
    Feb 2012
    Posts
    89

    Re: Reading a text file divided by tab

    I am acquainted with dealing the files in hard drive by designing codes in C language. I can’t tell you exactly how to make a code for your need. It will need some intensive research and time. But you can use the ‘strtok’ to pass the string pointer along with literal strings which have the required delimiters. In this method, every time you initialize ‘strtok’, it will pass null values instead of string pointers.

    This will help you to pass next token from the string that you have targeted. The best thing about ‘strtok’ is that it will start returning null values when t will fail to find more data.

  3. #3
    Join Date
    Feb 2012
    Posts
    91

    Re: Reading a text file divided by tab

    According to the method suggested by BBC123, the code might give you the data of your documents with tab strokes removed. But I think that it will mess the pattern of the data in which you have made it. By messed up data, I mean that though it might recognize the tab strokes in your data, it might fail to recognize ‘Enter’ command or maybe Shift + Enter’ whatever that you have used to go on the next line.

    Because of this, the data between the lines may appear continuous and you might need to take few more efforts to separate them. Adding code to recognize the Enter or any other command that is used to enter the next line will be more tedious.

  4. #4
    Join Date
    Feb 2012
    Posts
    88

    Re: Reading a text file divided by tab

    I agree with Elias Blackman and his concept of getting possible errors. But I think that if While command is added in loop such that value will go on incrementing, I think that script for getting tab strokes out of the data will start recognizing the difference between two lines. Every time the While loop is initialized the script should check for next valid tab stroke in the file. Also the output should be generated on next line; maybe you could use something close to \n command for getting the new line entry in the output.
    One cries because one is sad. For example, I cry because others are stupid, and that makes me sad.

  5. #5
    Join Date
    Feb 2012
    Posts
    96

    Re: Reading a text file divided by tab

    I made a script that I think will help you to get the tab strokes out of your notepad document. I used C++ to get the things done. I have posted the code for you which you might find helpful. I have used the getline method for the code to recognize the new line and to parse all the strings in the line, I have used istringstream class. I hope it is useful for you.


Similar Threads

  1. How to convert image text into a text file
    By Wadee in forum Windows Software
    Replies: 5
    Last Post: 02-12-2010, 06:33 PM
  2. Reading text file in VC++ display it in textbox
    By molocas in forum Software Development
    Replies: 1
    Last Post: 26-07-2010, 10:34 AM
  3. Problem reading a text file
    By Vodka in forum Software Development
    Replies: 5
    Last Post: 26-02-2010, 04:02 AM
  4. Reading file bit by bit
    By John Wilson in forum Software Development
    Replies: 4
    Last Post: 14-12-2009, 01:49 PM
  5. Reading text string from text file (PHP)
    By Moderate in forum Software Development
    Replies: 3
    Last Post: 16-01-2009, 03:27 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,578,541.04189 seconds with 17 queries