473,545 Members | 2,679 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Skip first 9 lines of file.

14 New Member
I appriate your work but...
guys i have another problm.....i wana skip first 9 lines from my data file and after skipping i wana read x,y,z at the end of file. i did but after while loop is end it again skip these 9 lines. how to solve this.

and also i wana distinguish these float data and unsigned data, as you can see in data file. after 9 lines, 6 lines are the float data, after this 6 lines are unsigned int.

actually this file has a point data information. float information are the vertices and int. infromation are the faces information.
this is the data...
#Version 1.0
Shell type : GENERIC
Projection Matrix
1.0000000000 0.0000000000 0.0000000000 0.0000000000
0.0000000000 1.0000000000 0.0000000000 0.0000000000
0.0000000000 0.0000000000 1.0000000000 0.0000000000
0.0000000000 0.0000000000 0.0000000000 1.0000000000
Number of Vertices : 59997
Number of Faces : 119990
29.4696752463 12.6605791420 30.6919154781
29.1161389891 13.2225081759 30.8961547223
25.8970270085 17.1671635879 32.5284062521
25.3111418518 16.7610352994 32.0368219549
27.4993616759 13.8120514401 30.4372772554
20.8197376962 18.3168655883 31.3811258705
7147 7401 7402
7403 7147 7402
7403 7402 7404
7403 7404 7405
7406 7403 7405
7406 7405 7150
------------------------------
and my programme is this......
Expand|Select|Wrap|Line Numbers
  1. struct GLpoint {
  2.     float x, y, z;
  3.     };
  4. GLpoint OBJ_VERTICES[30];
  5.  
  6. struct GLFace {
  7.     unsigned short v1, v2, v3;
  8. };
  9.  
  10.  
  11. int cnt = 0;
  12. int nb_Faces = 0;
  13.  
  14.  
  15.  
  16. int main()
  17. {
  18.         string line;
  19.         fstream file_op("c:\\temp2.txt", ios::in);
  20.  
  21.         if (!file_op)
  22.             return false;
  23.         else 
  24.         {
  25.             do
  26.             {
  27.                     getline(file_op,line);
  28.                     getline(file_op,line);
  29.                     getline(file_op,line);
  30.                     getline(file_op,line);
  31.                     getline(file_op,line);
  32.                     getline(file_op,line);
  33.                     getline(file_op,line);
  34.                     getline(file_op,line);
  35.                     getline(file_op,line);
  36.                     file_op >> OBJ_VERTICES[nb_Faces].x >> OBJ_VERTICES[nb_Faces].y >> OBJ_VERTICES[nb_Faces].z;
  37.                     nb_Faces++;
  38.             }while(!file_op.eof());
  39.             cout<<" \n\tno of lines = "<<nb_Faces<<endl;
  40.             cout<<OBJ_VERTICES[nb_Faces].x<<"    " << OBJ_VERTICES[nb_Faces].y<<"   " << OBJ_VERTICES[nb_Faces].z;
  41.             return true;            
  42.         }
  43. }
Nov 5 '07 #1
18 6259
sicarie
4,677 Recognized Expert Moderator Specialist
luckyyyyyy-

It is extremely rude to hijack someone else's thread, especially when you don't use code tags or anything else. I will split it off this time, but read through our Posting Guidelines, and follow them if you want to use this site.
Nov 5 '07 #2
sicarie
4,677 Recognized Expert Moderator Specialist
I appriate your work but...
guys i have another problm.....i wana skip first 9 lines from my data file and after skipping i wana read x,y,z at the end of file. i did but after while loop is end it again skip these 9 lines. how to solve this.
Keep 9 lines in buffer (don't print them out or manipulate them), and then check for eof.
and also i wana distinguish these float data and unsigned data, as you can see in data file. after 9 lines, 6 lines are the float data, after this 6 lines are unsigned int.
You can parse lines with strtok()
Nov 5 '07 #3
luckyyyyyy
14 New Member
Keep 9 lines in buffer (don't print them out or manipulate them), and then check for eof.

You can parse lines with strtok()


thanks.....

and yes i got it...the right code is this...
full code removed---------------------
but how to distiguish float and int values in this data...i want to store float values in GLpoint struct...and int values in GLface struct.......wh en it read it makes no any difference to float and int..
for example...
if (the end of float value)
then
read the int values and store in GLface struct...
Nov 5 '07 #4
sicarie
4,677 Recognized Expert Moderator Specialist
You can parse lines with strtok()
What's in the float's that's not in the ints?
Nov 5 '07 #5
luckyyyyyy
14 New Member
thanks.....

and yes i got it...the right code is this...
full code removed---------------------
but how to distiguish float and int values in this data...i want to store float values in GLpoint struct...and int values in GLface struct.......wh en it read it makes no any difference to float and int..
for example...
if (the end of float value)
then
read the int values and store in GLface struct...
--------------------------------------------------------------
i dont know what i did wrong to post my question...i read your posting guidline but i couln't find, just two r three things, its should be capital letter, its just my third post...ok i will try my best..
Nov 5 '07 #6
luckyyyyyy
14 New Member
--------------------------------------------------------------
i dont know what i did wrong to post my question...i read your posting guidline but i couln't find, just two r three things, its should be capital letter, its just my third post...ok i will try my best..
--------
ok i explain...

this is the data...

29.4696752463 12.6605791420 30.6919154781
29.1161389891 13.2225081759 30.8961547223
25.8970270085 17.1671635879 32.5284062521
25.3111418518 16.7610352994 32.0368219549
27.4993616759 13.8120514401 30.4372772554
20.8197376962 18.3168655883 31.3811258705
7147 7401 7402
7403 7147 7402
7403 7402 7404
7403 7404 7405
7406 7403 7405
7406 7405 7150

first six lines have values float x,y,z, . and last six has unsigned int fx,fy,fz...I wana store first six in x,y,z, and last six in fx,fy,fz. when reading this file...how to do this...i think there should be a if command....if (float vaues) then this....if(int value) then this...
Nov 5 '07 #7
sicarie
4,677 Recognized Expert Moderator Specialist
--------------------------------------------------------------
i dont know what i did wrong to post my question...i read your posting guidline but i couln't find, just two r three things, its should be capital letter, its just my third post...ok i will try my best..
You hijacked someone else's thread - I split it off. You did not use code tags, I filled them in for you. Thank you for reading the Guidelines, please follow them in your future posts.
Nov 5 '07 #8
sicarie
4,677 Recognized Expert Moderator Specialist
--------
ok i explain...

first six lines have values float x,y,z, . and last six has unsigned int fx,fy,fz...I wana store first six in x,y,z, and last six in fx,fy,fz. when reading this file...how to do this...i think there should be a if command....if (float vaues) then this....if(int value) then this...
Okay, so is it like that every time? Can you ahrd code the first 6 to be floats and the last six to be unsigned ints?

If not, then you have to look for patterns in the data. You can read text in different ways, I'm suggesting to read it in as a string and parse the string for something that the floats have that the unsigned ints don't. From there, you can do whatever you want with it - you have your if condition that will report true or false.
Nov 5 '07 #9
luckyyyyyy
14 New Member
You hijacked someone else's thread - I split it off. You did not use code tags, I filled them in for you. Thank you for reading the Guidelines, please follow them in your future posts.
-----------------
i hijacked someone else's thread...whats the meaning of hijack...really i dont know what i did wrong...may be "title is change" that's why...but i dont know...please ignor my mistake... thanks
Nov 5 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2967
by: Pjotr Wedersteers | last post by:
I have to process large files containing "logical" blocks of strings, each block varying in number of lines. .... Block number x string1 string2 .... string n Block number y et cetera.
3
26336
by: puzzlecracker | last post by:
I want to read lines and skip blank lines: would this work considering the lines can contain tabs, spaces, etc.? file.in: ------ line1 line2
12
926
by: FrancisC | last post by:
How can I open a file, skip first 2 lines and get the 50th character? EXP 0 R:\000\un\111\e00\e00noLog\1006\bdry_arc.e00 ARC 2 1 1 0 0 0 0 7 i.e., I want to get the "7" in the third line, how can I do that? thx!!
16
28354
by: Adam Witney | last post by:
Hi, Is it possible for the COPY command to read data from a file, but skip specific columns? Thanks Adam
1
2501
by: ntuyen01 | last post by:
Hi All, I have this data file with fix length(see below). I am able to insert it into the database using bcp, but now I want to skip (do not insert) the row which start with letter 'S' into the database. Is there away to do it? By the way I am using -F2 option to skip the first record. Here is my data: Record 1 04 XXX 2...
15
9180
by: eight02645999 | last post by:
hi, how can i skip printing the last line using loops (for /while) eg for line in open("file): print line. I want to skip printing last line of the file.thanks
3
20568
by: tjuiowa | last post by:
Hi I am trying to import a text file into a MS Access database. The first 11 lines of the text file are in a different format, so i would like to skip those lines and start at line 12. is there a quick and easy way to skip lines using VB in Access. Here is a sample of my text file: SDS 2.2 AD Results 1.0 Filename PlateID Assay...
2
9814
by: odin607 | last post by:
I'm making a little program to track what items I sell/buy how much of them how much it was to buy it and when I bought it. This program is only C (or trying to keep it that way) Theres a few files that im writing to to display all that information, but that's for another time. This post is to ask how to read from one of the files (it...
3
5078
by: blunt | last post by:
right the program is nearly complete just a couple of little tweaks and i should have it. The purpose of this program is to write config files for colubrius wireless access points but it's falling over in this section of code: while(line!=32){ fgets(c, 1, sourceFile); strncpy (compare,c,1); if...
0
7685
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7941
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7452
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6014
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5354
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5071
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3467
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1916
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
738
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.