Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 132,625 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,054 people online right now. Registration is fast and FREE... Join Now!




read data column wise

 
Reply to this topicStart new topic

read data column wise, can turbo c be used to read .txt files column wise

ankurbahri
post 5 Aug, 2008 - 09:07 PM
Post #1


New D.I.C Head

*
Joined: 3 Aug, 2008
Posts: 4

can some one please give a link to a web site or any piece of information that can help me read data in a .txt file column wise????
User is offlineProfile CardPM

Go to the top of the page

Martyr2
post 5 Aug, 2008 - 09:18 PM
Post #2


Programming Theoretician

Group Icon
Joined: 18 Apr, 2007
Posts: 5,062



Thanked 175 times

Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions


Perhaps you can explain further on what you mean by read by column. Files are horizontal. Columns are only separated row data. If I want to read down the first column I am going to loop through the rows reading a specific character(s) from each row.

CODE

test 1
test 2
test 3


This is column data (2 columns) but is actually three rows of data and if I want to read the number here (column 2) I am going to read character 6 from each row. So I would loop through the rows and read character 6 in that loop.

Hope that makes sense. smile.gif
User is offlineProfile CardPM

Go to the top of the page

ankurbahri
post 5 Aug, 2008 - 10:58 PM
Post #3


New D.I.C Head

*
Joined: 3 Aug, 2008
Posts: 4

for example mt file looks somthing like this:-

a b c d e f
1 2 3 4 5 6
7 8 9 10 11 12
13 14 15 61 62 27


now if i want to read say the data of only column d i.e 4,10,61... then how do i do it???????

User is offlineProfile CardPM

Go to the top of the page

gabehabe
post 6 Aug, 2008 - 03:37 AM
Post #4


Working Girl.

Group Icon
Joined: 6 Feb, 2008
Posts: 5,440



Thanked 94 times

Dream Kudos: 2625

Expert In: ruling the world.

My Contributions


First, you would want to loop through the first line to find a number representation of column d. Make it ignore the spaces, this will result in a column number of 4.

Now read until you reach a '\n' character (new line)

Then, loop through each row until you find the column that you are looking for. Read this in from the file, and continue until you reach a new line.

Hope this helps smile.gif
User is online!Profile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/23/08 03:29AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month