read string from a file

anxx0018
anxx0018 used Ask the Experts™
on
I have the below file.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;  file :  CUTITResults.scm
;;  user :  #f
;;  date :  Wed Dec 11 17:00:41 2002
;;  part :  ()
;;  acis :  CUTITResults.sat

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;  features "feature190"

(feature ((name "feature190")
          (type featureGroup)
          (level ())
          (partName ())
          (stockName "stock")
          (volumeName "tsm128-volume")
          (methodNames ("am220"))
          ))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;  methods

(method ((name "am220")
         (type abstractMethod)
         (status ())
         (featureName "feature190")
         (childrenNames ("tsm128" "tsm130" "tsm134" "tsm136"))
         ))

(method ((name "tsm128")
         (type toolShapeMethod)
         (status ())
         (featureName "feature190")
         (parentName "am220")
         (toolShapeName "flatEndMill")
         (toolAxisO (gvector 0 0 1))
         (entranceList (list
                         (gvector 1 0 0)
                         (gvector 0 0 1)
                         (gvector 0 -1 0)
                         (gvector 0 0 -1)
                         ))
         (removalVolumeName "tsm128-volume")
         (Volume removed 40603.4808382494)
         ))

(method ((name "tsm130")
         (type toolShapeMethod)
         (status ())
         (featureName "feature190")
         (parentName "am220")
         (toolShapeName "flatEndMill")
         (toolAxisO (gvector 0 0 -1))
         (entranceList (list
                         (gvector 1 0 0)
                         (gvector 0 0 1)
                         (gvector 0 -1 0)
                         (gvector 0 0 -1)
                         ))
         (removalVolumeName "tsm128-volume")
         (Volume removed 40603.4808382494)
         ))

(method ((name "tsm134")
         (type toolShapeMethod)
         (status ())
         (featureName "feature190")
         (parentName "am220")
         (toolShapeName "ballEndMill")
         (toolAxisO (gvector 0 0 1))
         (entranceList (list
                         (gvector 1 0 0)
                         (gvector 0 0 1)
                         (gvector 0 -1 0)
                         (gvector 0 0 -1)
                         ))
         (removalVolumeName "tsm128-volume")
         (Volume removed 40603.4808382494)
         ))

(method ((name "tsm136")
         (type toolShapeMethod)
         (status ())
         (featureName "feature190")
         (parentName "am220")
         (toolShapeName "ballEndMill")
         (toolAxisO (gvector 0 0 -1))
         (entranceList (list
                         (gvector 1 0 0)
                         (gvector 0 0 1)
                         (gvector 0 -1 0)
                         (gvector 0 0 -1)
                         ))
         (removalVolumeName "tsm128-volume")
         (Volume removed 40603.4808382494)
         ))



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;  features "feature194"

(feature ((name "feature194")
          (type featureGroup)
          (level ())
          (partName ())
          (stockName "stock")
          (volumeName "tsm140-volume")
          (methodNames ("am226"))
          ))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;  methods

(method ((name "am226")
         (type abstractMethod)
......
......
......

I want to read this file and get the information including feature name, "tsm" methods, "tsm" method name, toolShapeName, and toolAxisO, the value of the Volume removed. Write these information into a database.

Could you suggest me a good method of reading information from this file?

thank you!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
#include <iostream>
#include <string>

using namespace std;

void main()
{
  iostream inFile("file.txt");
  String str_Line;


  while (!inFile.eof())
  {
     //Will get a single line of text and store it in str_Line
     getline(in, str_Line);
  }
}

Commented:
FYI:
String should be string

Author

Commented:
Thank you for your answers.

for getline's parameters, what does the "in" stand for?

I also have the problem, if I did not add std:: before string, I have problem when compiling.

thanks.
 
Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

Commented:
been using java

Commented:
inFile sorry

Author

Commented:
I have another question,

how can I get exact part from each line efficiently,

such as:

 for the feature part, I just need the
1st line: (feature ((name "feature190"), I need feature190.

for ("am" part), (method ((name "am220") ... ... , I just need to count how many "tsm..."s from the last line information

for ("tsm" part)
what I need are :
1st line: (method ((name "tsm128")  I need tsm128
skip 2, 3, 4, 5 lines
6th line: (toolShapeName "flatEndMill")  I need flatEndMill
7th line: (toolAxisO (gvector 0 0 1))   I need (gvector 0 0 1)

sorry for asking, I am a greenhand.

thanks.

by the way, what is "been using java"?

Author

Commented:
I have another question,

how can I get exact part from each line efficiently,

such as:

 for the feature part, I just need the
1st line: (feature ((name "feature190"), I need feature190.

for ("am" part), (method ((name "am220") ... ... , I just need to count how many "tsm..."s from the last line information

for ("tsm" part)
what I need are :
1st line: (method ((name "tsm128")  I need tsm128
skip 2, 3, 4, 5 lines
6th line: (toolShapeName "flatEndMill")  I need flatEndMill
7th line: (toolAxisO (gvector 0 0 1))   I need (gvector 0 0 1)

sorry for asking, I am a greenhand.

thanks.

by the way, what is "been using java"?

Author

Commented:
Thank you for your answers.

for getline's parameters, what does the "in" stand for?

I also have the problem, if I did not add std:: before string, I have problem when compiling.

thanks.
 

Author

Commented:
Could anybody help me with my other questions listed above about string? Thank you very much!

Author

Commented:
Very good. I can use it now. Thank you very much!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial