Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: ,

Sponsored Links


Reading a text file divided by tab

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 07-09-2012
Cooper Sheldon's Avatar
Member
 
Join Date: Sep 2012
Posts: 19
Reading a text file divided by tab

Sponsored Links
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,
Quote:
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?

Reply With Quote
  #2  
Old 07-09-2012
Member
 
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.
Reply With Quote
  #3  
Old 07-09-2012
Elias Blackman's Avatar
Member
 
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.
Reply With Quote
  #4  
Old 08-09-2012
Anuja Darzi's Avatar
Member
 
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.
Reply With Quote
  #5  
Old 08-09-2012
Tech^Geek's Avatar
Member
 
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.

Reply With Quote
Reply

  TechArena Community > Software > Software Development


Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Reading a text file divided by tab"
Thread Thread Starter Forum Replies Last Post
How to convert image text into a text file Wadee Windows Software 5 02-12-2010 05:33 PM
Reading text file in VC++ display it in textbox molocas Software Development 1 26-07-2010 10:34 AM
Reading XML file with ASP Dharamsi Software Development 4 10-03-2010 09:47 PM
Problem reading a text file Vodka Software Development 5 26-02-2010 03:02 AM
Reading text string from text file (PHP) Moderate Software Development 3 16-01-2009 02:27 PM


All times are GMT +5.5. The time now is 11:00 PM.