I wondering if anybody can help me. I intend to use CFile to trap interested data for a unstructured text file. Unstructured text file, meaning data is not sorted. Following is the part of the text file:
Code:
============================================================================================================================
OFFPIPE - OFFSHORE PIPELINE ANALYSIS SYSTEM - VERSION NO: 2.07 GJ DATE - 8/ 4/2010 TIME - 12:48:40 PAGE 37
PROJECT - PCSB 6IN BEA TO BEB SIDEWALK - LIFTING VIA DLB264 JOB NO. - 50044
USER ID - I.HAMID LICENSED USER: GLOBAL OFFSHORE MALAYSIA SDN BHD CASE 1
============================================================================================================================
S T A T I C P I P E C O O R D I N A T E S, F O R C E S A N D S T R E S S E S
===================================================================================================================================
NODE PIPE X Y Z HORIZ VERT PIPE TENSILE HOOP BENDING STRESSES TOTAL PERCNT
NO. SECTION COORD COORD COORD ANGLE ANGLE LENGTH STRESS STRESS VERT HORIZ STRESS YIELD
(FEET) (FEET) (FEET) (DEG ) (DEG ) (FEET) (KSI ) (KSI ) (KSI ) (KSI ) (KSI ) (PCT )
===================================================================================================================================
1 SEABED 30.00 -242.92 0.00 0.000 -0.035 0.000 -0.11 0.00 0.00 0.00 0.11 0.17
2 SEABED 15.00 -242.90 0.00 0.000 -0.060 15.000 -0.11 0.00 0.44 0.00 0.55 0.84
3 LAYBARGE 0.00 -242.89 0.00 0.000 0.006 30.000 -0.11 0.00 -3.05 0.00 3.16 4.86
5 SEABED -25.00 -242.91 0.00 0.000 0.010 55.000 -0.11 0.00 0.39 0.00 0.50 0.77
6 SEABED -50.00 -242.91 0.00 0.000 -0.002 80.000 -0.11 0.00 -0.03 0.00 0.14 0.21
7 SEABED -75.00 -242.91 0.00 0.000 0.000 105.000 -0.11 0.00 -0.03 0.00 0.14 0.21
9 SEABED -100.00 -242.91 0.00 0.000 0.000 130.000 -0.11 0.00 0.00 0.00 0.11 0.17
10 SEABED -125.00 -242.91 0.00 0.000 0.000 155.000 -0.11 0.00 0.00 0.00 0.11 0.17
11 SEABED -150.00 -242.91 0.00 0.000 0.000 180.000 -0.11 0.00 -0.03 0.00 0.14 0.21
13 SEABED -175.00 -242.91 0.00 0.000 0.000 205.000 -0.11 0.00 0.00 0.00 0.11 0.17
14 SEABED -200.00 -242.91 0.00 0.000 0.000 230.000 -0.11 0.00 0.00 0.00 0.11 0.17
15 SEABED -225.00 -242.91 0.00 0.000 0.000 255.000 -0.11 0.00 -0.03 0.00 0.14 0.21
17 SEABED -245.00 -242.91 0.00 0.000 0.000 275.000 -0.11 0.00 0.01 0.00 0.11 0.17
18 SEABED -265.00 -242.91 0.00 0.000 0.000 295.000 -0.11 0.00 0.00 0.00 0.11 0.17
19 SEABED -285.00 -242.91 0.00 0.000 0.000 315.000 -0.11 0.00 0.00 0.00 0.11 0.17
20 SEABED -305.00 -242.91 0.00 0.000 0.000 335.000 -0.11 0.00 0.00 0.00 0.11 0.17
21 SEABED -325.00 -242.91 0.00 0.000 0.000 355.000 -0.11 0.00 0.00 0.00 0.11 0.17
22 SEABED -345.00 -242.91 0.00 0.000 0.000 375.000 -0.11 0.00 0.00 0.00 0.11 0.17
23 SEABED -365.00 -242.91 0.00 0.000 0.000 395.000 -0.11 0.00 0.00 0.00 0.11 0.17
24 SEABED -385.00 -242.91 0.00 0.000 0.000 415.000 -0.11 0.00 0.00 0.00 0.11 0.17
25 SEABED -405.00 -242.91 0.00 0.000 0.000 435.000 -0.11 0.00 0.00 0.00 0.11 0.17
26 SEABED -425.00 -242.91 0.00 0.000 0.000 455.000 -0.11 0.00 0.00 0.00 0.11 0.17
27 SEABED -445.00 -242.91 0.00 0.000 0.000 475.000 -0.11 0.00 0.00 0.00 0.11 0.17
28 SEABED -465.00 -242.91 0.00 0.000 0.000 495.000 -0.11 0.00 0.00 0.00 0.11 0.17
29 SEABED -485.00 -242.91 0.00 0.000 0.000 515.000 -0.11 0.00 0.00 0.00 0.11 0.17
30 SEABED -505.00 -242.91 0.00 0.000 0.000 535.000 -0.11 0.00 0.00 0.00 0.11 0.17
31 SEABED -525.00 -242.91 0.00 0.000 0.000 555.000 -0.11 0.00 0.00 0.00 0.11 0.17
32 SEABED -545.00 -242.91 0.00 0.000 0.000 575.000 -0.11 0.00 0.00 0.00 0.11 0.17
As you can see, there are some data in numeric and some in text. Where, in the middle is just empty spaces, not tabs. I need to separate it, store it in vector of int and CString.
The problem is, I got no idea how to do the reading, and storing in variable (with respect of numeric or CSTring data).
Can anybody give me some idea? Thanks for reading this
Re: Reading Unstructure Text File using CFile in MFC
First off, this text file is not really unstructured. It is not even unsorted: It is properly sorted by the NODE NO. field.
The CFile class isn't really suitible for data like this. It dosn't even have a method to read in individual lines of a text file. In fact, even MS's own documentation on CFile recommends to use iostream classes for data like that.
Are there really compelling reasons for you to use CFile? If not, I think you should reconsider your choice.
Re: Reading Unstructure Text File using CFile in MFC
Thanks Guys.
Actually there a alot more of that file that I didn't paste into this post. Alot f rubbish data and the column is not always arrange in that sequence plus sometime its include new column for new data type.
Re: Reading Unstructure Text File using CFile in MFC
Philip's suggestion seems the best for this (relatively) simple case. If you encounter more complex structures to parse, you could use the boost's spirit library (http://boost-spirit.com/home/doc/).
Re: Reading Unstructure Text File using CFile in MFC
Originally Posted by Eri523
First off, this text file is not really unstructured. It is not even unsorted: It is properly sorted by the NODE NO. field.
The CFile class isn't really suitible for data like this. It dosn't even have a method to read in individual lines of a text file. In fact, even MS's own documentation on CFile recommends to use iostream classes for data like that.
Are there really compelling reasons for you to use CFile? If not, I think you should reconsider your choice.
HTH
But there is a class derived from it, CStdioFile, that is specifically for text files.
Bookmarks