i have a ASCII file that contain 3 line of numbers as below:
307.1642127.1642334.3412154.3412334.341288.2652 271.330896.104
127.1642307.1642285.1534105.1530285.153287.3500 272.2500214.227
285.1532105.1532307.1642127.1642307.164287.2001 272.395952.055


i just want to extract red number which is its stand for angle/azimuth ... so how can i do that in vb.net? the problem here is its not separated by any space or comma delimiter... so how could i extract this information?

Edited 6 Years Ago by wasyazwan: n/a

How is that data structured? Are those numbers always guaranteed to be in the exact same position? If so you could read the middle of the string. Or will the number always start N positions after the N'th decimal number?

How is that data structured? Are those numbers always guaranteed to be in the exact same position? If so you could read the middle of the string. Or will the number always start N positions after the N'th decimal number?

yes... its always in same position.... actually the data structured are as below:
29 Pkt 28 Pkt 27 Pkt 285.1532105.1532307.1642127.1642307.164287.2001 272.395952.055 52.055
28 Pkt 29 Pkt 30 Pkt 105.1532285.1532264.450684.4457 264.450280.2100 279.390043.566 43.566

I want to extract those red data and then export it into a new output file with a new format as below:
29-28 307-16-42 52.055
28-29 264-45-02 43.566

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
    Dim lines As String() = New String() { _
    "29 Pkt 28 Pkt 27 Pkt 285.1532105.1532307.1642127.1642307.164287.2001 272.395952.055 52.055", _
    "28 Pkt 29 Pkt 30 Pkt 105.1532285.1532264.450684.4457 264.450280.2100 279.390043.566 43.566"}

    For Each line As String In lines
      Dim fields(5) As String
      fields(0) = line.Substring(0, 2)
      fields(1) = line.Substring(7, 2)
      fields(2) = line.Substring(53, 3)
      fields(3) = line.Substring(57, 2)
      fields(4) = line.Substring(59, 2)
      fields(5) = line.Substring(84, 6)
      Console.WriteLine("{0}-{1} {2}-{3}-{4} {5}", fields)
    Next
  End Sub

Results in:

29-28 307-16-42 52.055
28-29 264-45-02 43.566

thanks for your fast response sknake... im really appreciated for ur helping... for your information that data are contain in the ASCII file.. so how can i read those strings from the file.. and one more thing is there are another data that i need to extract from the strings... that is the line code.. the example are as below:
29 Pkt 28 Pkt 27 Pkt 285.1532105.1532307.1642127.1642307.164287.2001 272.395952.055 52.055 2009120222
28 Pkt 29 Pkt 30 Pkt 105.1532285.1532264.450684.4457 264.450280.2100 279.390043.566 43.566 2009120214
so i want to add some data filtering in my software... if line code =22 then software will extract data from that line and export into new formatted ascii file.. then if the line code =14, that line will be ignored from the extraction process.. it means that the line with the code 14 will be not use...

Every time you post sample data it changes :P Please post _complete_ data.
Here is an example of filtering on line code 22, reading in from a file, and writing out to a file:

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
    Const inFile As String = "C:\sampledata.txt"
    Const outFile As String = "C:\sampledata_new.txt"
    Using sr As New System.IO.StreamReader(inFile)
      Using sw As New System.IO.StreamWriter(outFile, False)
        Dim line As String
        Do
          line = sr.ReadLine()
          If Not String.IsNullOrEmpty(line) Then
            Dim fields(6) As String
            fields(0) = line.Substring(0, 2)
            fields(1) = line.Substring(7, 2)
            fields(2) = line.Substring(53, 3)
            fields(3) = line.Substring(57, 2)
            fields(4) = line.Substring(59, 2)
            fields(5) = line.Substring(84, 6)
            fields(6) = line.Substring(99, 2)
            If (Convert.ToInt32(fields(6)) = 22) Then 'If line # = 22
              sw.WriteLine(String.Format("{0}-{1} {2}-{3}-{4} {5} {6}", fields))
              'Console.WriteLine(String.Format("{0}-{1} {2}-{3}-{4} {5} {6}", fields))
            End If
          End If
        Loop Until line Is Nothing
        sw.Flush()
        sw.Close()
      End Using
    End Using
  End Sub

sorry my friend... here is i upload the real input file... so from the file you can see the structure of the data.. i have try your code and it come out with a little problem.. the problem is with the last line..
102 Pkt 129 Pkt 313.1320133.13201.0810 181.08101.0810 88.1805 271.415557.599 57.599 57.574 2000020211501325

the output file cannot be produce as below:

102-129 1-08-10 57.574

for the line no 6 its succesfully produced with the correct format.

Attachments
PUBLT     167_89                                            9000      Pkt                 9001      Pkt                                 0.0000  180.00000.0000  90.0000 270.000062.225    62.225    62.225    2000020208573222                                                  
PUBLT     167_89                                            9002      Pkt                 9000      Pkt                                 0.0000  180.00000.0000  90.0000 270.000032.225    32.225    32.225    2000020209003222                              9000      9001      
PUBLT     167_89                                            9002      Pkt                 9001      Pkt                                 0.0000  180.00000.0000  90.0000 270.000019.072    19.072    19.072    2000020209013222                              9000      9001      
PUBLT     167_89                                            2         BKL       78/906    1         BKL                 0.0000  0.0000  40.2730 220.273040.2730 89.5859 270.011180.961    80.961    80.961    2000020209063211                                                  
PUBLT     167_89                                            2         BKL       78/906    1         BKL                                 40.2730 220.273040.2730 89.5859 270.011180.961    80.961    80.961    2000020209150015                                                  
PUBLT     167_89              1         BKL                 2         BKL       78/906    3         Pkt                 40.2730 220.2730132.0903312.0857132.090090.5500 269.050049.775    49.775    49.769    2000020209182512                                                  
PUBLT     167_89              1         BKL                 2         BKL       78/906    4         Pkt                 40.2730 220.2730218.075138.0748 218.075090.0000 270.0000103.997   103.997   103.997   2000020209291912                                                  
PUBLT     167_89              1         BKL                 2         BKL       78/906    5         Pkt                 40.2730 220.2730282.5652102.5647282.565089.2000 270.400066.008    66.008    66.004    2000020209431512                                                                                          
PUBLT     167_89              112       Pkt                 102       Pkt                 129       Pkt                 313.1320133.13201.0810  181.08101.0810  88.1805 271.415557.599    57.599    57.574    2000020211501325

That file is quite a bit different than what you posted here. All of your examples were using "Pkt" and there are "Bkl" lines in the file. Should those be ignored or treated the same? Can you also include examples for a few of the lines from data included in x.txt?

That file is quite a bit different than what you posted here. All of your examples were using "Pkt" and there are "Bkl" lines in the file. Should those be ignored or treated the same? Can you also include examples for a few of the lines from data included in x.txt?

ya... just ignore the other data... just extract data as before....

Here is my sample code..

Private Sub kira_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kira.Click
        Const inFile As String = "C:\test2.fbk"
        Const outFile As String = "C:\x_new.DAT"
        Using sr As New System.IO.StreamReader(inFile)
            Using sw As New System.IO.StreamWriter(outFile, False)
                Dim line As String
                Do
                    line = sr.ReadLine()
                    If Not String.IsNullOrEmpty(line) Then
                        Dim fields(6) As String
                        fields(0) = line.Substring(60, 4)
                        fields(1) = line.Substring(90, 4)
                        fields(2) = line.Substring(152, 3)
                        fields(3) = line.Substring(155, 2)
                        fields(4) = line.Substring(157, 2)
                        fields(5) = line.Substring(196, 7)
                        fields(6) = line.Substring(220, 2)
                        If (Convert.ToInt32(fields(6)) = 12 Or (fields(6)) = 11 Or (fields(6)) = 15 Or (fields(6)) = 13 Or (fields(6)) = 23 Or (fields(6)) = 25) Then 'If line # = 12
                            sw.WriteLine(String.Format("BM {0}-{1} {2}-{3}-{4} {5} {6}", fields))
                            'Console.WriteLine(String.Format("{0}-{1} {2}-{3}-{4} {5} {6}", fields))
                        End If
                    End If
                Loop Until line Is Nothing
                sw.Flush()
                sw.Close()
            End Using
        End Using
    End Sub

And the result i get like this :
BM 2 -1 40.-27-30 80.961 11
BM 2 -1 40.-27-30 80.961 15
BM 2 -3 132-.0-90 49.769 12
BM 2 -4 218-.0-75 103.997 12
BM 2 -5 282-.5-65 66.004 12
BM 102 -129 1.0-81-0 57.574 25

so what i want actually are as below:
BM 2-1 40-27-30 80.961 11
BM 2-1 40-27-30 80.961 15
BM 2-3 132-09-00 49.769 12
BM 2-4 218-07-50 103.997 12
BM 2-5 282-56-50 66.004 12
BM 102-129 1-08-10 57.574 25

Ew, I see whats happening here. The decimal can float and they pad right with white spaces. Here is updated code.

'Imports System.Linq
  Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
    Const inFile As String = "C:\x.txt"
    Const outFile As String = "C:\x_new.txt"
    Dim lineCodes As Integer() = New Integer() {12, 11, 15, 13, 23, 25}
    Using sr As New System.IO.StreamReader(inFile)
      Using sw As New System.IO.StreamWriter(outFile, False)
        Dim line As String
        Do
          line = sr.ReadLine()
          If Not String.IsNullOrEmpty(line) Then
            Dim fields(6) As String
            fields(0) = line.Substring(60, 4).Trim()
            fields(1) = line.Substring(90, 4).Trim()

            '2-4 are a floating section in the file
            Dim chunk As String() = line.Substring(152, 8).Split(".")
            'fields(2) = line.Substring(152, 3).Trim() 'Problem
            'fields(3) = line.Substring(155, 2).Trim() 'Problem
            'fields(4) = line.Substring(157, 2).Trim() 'Problem
            fields(2) = chunk(0).Trim()
            fields(3) = chunk(1).Substring(0, 2).Trim()
            fields(4) = chunk(1).Substring(2, 2).Trim()
            fields(5) = line.Substring(196, 7).Trim()
            fields(6) = line.Substring(220, 2).Trim()


            Dim code As Integer = Convert.ToInt32(fields(6))
            If lineCodes.Contains(code) Then
              sw.WriteLine(String.Format("BM {0}-{1} {2}-{3}-{4} {5} {6}", fields))
              'Console.WriteLine(String.Format("[" + lineNbr.ToString() + "] " + "BM {0}-{1} {2}-{3}-{4} {5} {6}", fields))
            End If
          End If
        Loop Until line Is Nothing
        sw.Flush()
        sw.Close()
      End Using
    End Using
  End Sub

Be sure to add the Imports System.Linq to the top of the class.

Ew, I see whats happening here. The decimal can float and they pad right with white spaces. Here is updated code.

'Imports System.Linq
  Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
    Const inFile As String = "C:\x.txt"
    Const outFile As String = "C:\x_new.txt"
    Dim lineCodes As Integer() = New Integer() {12, 11, 15, 13, 23, 25}
    Using sr As New System.IO.StreamReader(inFile)
      Using sw As New System.IO.StreamWriter(outFile, False)
        Dim line As String
        Do
          line = sr.ReadLine()
          If Not String.IsNullOrEmpty(line) Then
            Dim fields(6) As String
            fields(0) = line.Substring(60, 4).Trim()
            fields(1) = line.Substring(90, 4).Trim()

            '2-4 are a floating section in the file
            Dim chunk As String() = line.Substring(152, 8).Split(".")
            'fields(2) = line.Substring(152, 3).Trim() 'Problem
            'fields(3) = line.Substring(155, 2).Trim() 'Problem
            'fields(4) = line.Substring(157, 2).Trim() 'Problem
            fields(2) = chunk(0).Trim()
            fields(3) = chunk(1).Substring(0, 2).Trim()
            fields(4) = chunk(1).Substring(2, 2).Trim()
            fields(5) = line.Substring(196, 7).Trim()
            fields(6) = line.Substring(220, 2).Trim()


            Dim code As Integer = Convert.ToInt32(fields(6))
            If lineCodes.Contains(code) Then
              sw.WriteLine(String.Format("BM {0}-{1} {2}-{3}-{4} {5} {6}", fields))
              'Console.WriteLine(String.Format("[" + lineNbr.ToString() + "] " + "BM {0}-{1} {2}-{3}-{4} {5} {6}", fields))
            End If
          End If
        Loop Until line Is Nothing
        sw.Flush()
        sw.Close()
      End Using
    End Using
  End Sub

Be sure to add the Imports System.Linq to the top of the class.

Its work... thanks a lot my friend....
if you have a time could you help me to solve my another thread..? because no one give the solution yet for that problem...

I can try, but no guarantees :P Message me the thread or post it here

You can open the thread with title "Extract data from file and then append it to another file "
Actually that thread is extension of this thread. I want to extract data from another file and then append the extracted data into the output file from this thread.

Edited 6 Years Ago by wasyazwan: n/a

I can try, but no guarantees :P Message me the thread or post it here

the thread are as below... im really hope that you will respond me whether you have a solution or not for this problem...

I have a file that contain data structure as below:
L,13206,11,02,06,000,3981.100
19,22,25,26,19
END
L,13207,11,02,06,000,6561.000
22,24,7,8,9,25,22
END
K,1,P
-18970.811,53728.643,BKL,,e-Coord,M
END
L,13207,11,02,06,000,6561.000
22,24,7,8,9,25,22
END
K,45,P
-18972.811,53723.643,BKL,,e-Coord,M
END

so how can i extract the red data and export it into a new output file with new structured as below:
C 1 -18970.811 53728.643
C 45 -18972.811 53723.643

One more thing is i want to append that new formatted data into old ready file that already contain old data... new formatted data will be append to the top of the old file..

Its work... thanks a lot my friend....
if you have a time could you help me to solve my another thread..? because no one give the solution yet for that problem...

how can i put another condition in the loop to not extract the line if the fields(5) equals to 0.000 ?

Sub Format_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles format.Click

        'Const inFile As String =""
        'Const outFile As String = "C:\x_newwww.txt"
        'WriteLine(String.Format("# Observations"))
        Dim lineCodes As Integer() = New Integer() {12, 11, 15, 13, 23, 25}
        Using sr As New System.IO.StreamReader(InputPath)
            Using sw As New System.IO.StreamWriter(datf, False)
                Dim line As String
                Do
                    line = sr.ReadLine()
                    If Not String.IsNullOrEmpty(line) Then
                        Dim fields(6) As String
                        fields(0) = line.Substring(60, 4).Trim()
                        fields(1) = line.Substring(90, 4).Trim()

                        '2-4 are a floating section in the file
                        Dim chunk As String() = line.Substring(152, 8).Split(".")
                        'fields(2) = line.Substring(152, 3).Trim() 'Problem
                        'fields(3) = line.Substring(155, 2).Trim() 'Problem
                        'fields(4) = line.Substring(157, 2).Trim() 'Problem
                        fields(2) = chunk(0).Trim()
                        fields(3) = chunk(1).Substring(0, 2).Trim()
                        fields(4) = chunk(1).Substring(2, 2).Trim()
                        fields(5) = line.Substring(196, 7).Trim()
                        fields(6) = line.Substring(220, 2).Trim()

                        'Dim distance As Double = Convert.ToInt32(fields(5))
                        'MsgBox(distance)
                        Dim code As Integer = Convert.ToInt32(fields(6))
                        If (lineCodes.Contains(code)) Then 'AndAlso (distance <> 0) Then
                            sw.WriteLine(String.Format("BM {0}-{1}  {2}-{3}-{4} {5}", fields))
                            'Console.WriteLine(String.Format("[" + lineNbr.ToString() + "] " + "BM {0}-{1} {2}-{3}-{4} {5} {6}", fields))
                        End If
                    End If
                Loop Until line Is Nothing
                sw.Flush()
                sw.Close()
            End Using
        End Using

that's my code... what i want to do is to put another condition besides to trace the line code.. i also want to filter the field(5).. so if the value of the field(5) equal to value 0.00 then maybe my system will ask the user either to continue the process by ignoring that line from extracting process or just stop the process to review back the input data... can i do that...

Try something like this:

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
    Const inFile As String = "C:\x.txt"
    Const outFile As String = "C:\x_new.txt"
    Dim lineCodes As Integer() = New Integer() {12, 11, 15, 13, 23, 25}
    Using sr As New System.IO.StreamReader(inFile)
      Using sw As New System.IO.StreamWriter(outFile, False)
        Dim line As String
        Do
          line = sr.ReadLine()
          If Not String.IsNullOrEmpty(line) Then
            Dim fields(6) As String
            fields(0) = line.Substring(60, 4).Trim()
            fields(1) = line.Substring(90, 4).Trim()

            '2-4 are a floating section in the file
            Dim chunk As String() = line.Substring(152, 8).Split(".")
            'fields(2) = line.Substring(152, 3).Trim() 'Problem
            'fields(3) = line.Substring(155, 2).Trim() 'Problem
            'fields(4) = line.Substring(157, 2).Trim() 'Problem
            fields(2) = chunk(0).Trim()
            fields(3) = chunk(1).Substring(0, 2).Trim()
            fields(4) = chunk(1).Substring(2, 2).Trim()
            fields(5) = line.Substring(196, 7).Trim()
            fields(6) = line.Substring(220, 2).Trim()


            Dim code As Integer = Convert.ToInt32(fields(6))
            If lineCodes.Contains(code) Then
              System.Diagnostics.Debugger.Break()
              Dim distance As Decimal = Decimal.Parse(fields(5))
              If (distance = 0) Then
                If (MessageBox.Show("Distance equals 0. Do you want to import this record?", Me.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) <> Windows.Forms.DialogResult.Yes) Then
                  Continue Do 'Skips writing the line
                End If
              End If
              sw.WriteLine(String.Format("BM {0}-{1} {2}-{3}-{4} {5} {6}", fields))
              'Console.WriteLine(String.Format("[" + lineNbr.ToString() + "] " + "BM {0}-{1} {2}-{3}-{4} {5} {6}", fields))
            End If
          End If
        Loop Until line Is Nothing
        sw.Flush()
        sw.Close()
      End Using
    End Using
  End Sub

i have attached the sample file for your reference... i have testing your code and after running the application, my VS2008 highlighted the code System.Diagnostics.Debugger.Break(). so whats the problem? can you test it with that sample file...

Attachments
PUBLT     554_2007                                          2         BKL                 1         BKL                 0.0000  0.0000  253.140073.1400 253.140088.0007 271.595343.770    43.770    43.743    2007082808074711                                                  
PUBLT     554_2007            1         BKL                 2         BKL                 3         BKL                 253.140073.1400 165.2300345.2300165.230088.2336 271.364033.539    33.539    33.526    2007082808173912                                                  
PUBLT     554_2007            1         BKL                 2         BKL                 4         Pkt                 253.140073.1400 77.3423 257.342377.3423 90.2155 269.3819108.833   108.833   108.831   2007082808323512                                                  
PUBLT     554_2007            2         BKL                 4         Pkt                 5         Pkt                 257.342377.3423 111.2140291.2140111.214090.1433 269.453380.961    80.961    80.960    2007082808421212                                                  
PUBLT     554_2007            4         Pkt                 5         Pkt                 6         BKB                 291.2140111.2140269.310089.3100 269.310088.0007 272.000331.077    31.077    31.058    2007082808564312                                                  
PUBLT     554_2007            4         Pkt                 5         Pkt                 6         BKB                 291.2140111.2140269.310089.3100 269.31000.0000  0.0000  0.000     0.000     0.000     2007082809071825                                                  
PUBLT     554_2007            4         Pkt                 5         Pkt                 7         Pkt                 291.2140111.214068.2836 248.283668.2836 90.2332 269.362860.178    60.178    60.177    2007082809151612                                                  
PUBLT     554_2007                                          7         Pkt                 5         Pkt                 0.0000  0.0000  0.0000  0.0000  0.0000  92.0008 268.001060.214    60.214    60.177    200708290821113                                                   
PUBLT     554_2007            5         Pkt                 7         Pkt                 8         BKB                 248.283668.2836 102.5650282.5650102.565088.3917 271.20436.268     6.268     6.266     2007082908310712                                                  
PUBLT     554_2007            5         Pkt                 7         Pkt                 8         BKB                 248.283668.2836 102.5650282.5650102.56500.0000  0.0000  0.000     0.000     0.000     2007082908424425                                                  
PUBLT     554_2007            5         Pkt                 7         Pkt                 9         Pkt                 248.283668.2836 105.1400285.1400105.140088.0007 272.000541.672    41.672    41.647    2007082908522512                                                  
PUBLT     554_2007            7         Pkt                 9         Pkt                 10        BKB                 285.1400105.1400194.223014.2230 194.223088.2336 271.364070.294    70.294    70.266    2007082909020212                                                  
PUBLT     554_2007            9         Pkt                 10        BKB                 11        Pkt                 14.2230 194.2230276.333896.3350 276.334490.2155 269.381946.320    46.320    46.319    2007082909163312                                                  
PUBLT     554_2007            10        BKB                 11        Pkt                 12        Pkt                 96.3344 276.3344252.580072.5800 252.580090.1433 269.453355.753    55.753    55.753    2007082909270812                                                  
PUBLT     554_2007            11        Pkt                 12        Pkt                 13        BKB                 72.5800 252.5800141.3910321.3910141.391088.0007 272.000312.225    12.225    12.218    2007082909370612                                                  
PUBLT     554_2007            11        Pkt                 12        Pkt                 13        BKB                 72.5800 252.5800141.3910321.3910141.39100.0000  0.0000  0.000     0.000     0.000     2007082909470125                                                  
PUBLT     554_2007            11        Pkt                 12        Pkt                 14        Pkt                 72.5800 252.5800349.1250169.1250349.125090.2332 269.363682.875    82.875    82.873    2007082909545712                                                  
PUBLT     554_2007            12        Pkt                 14        Pkt                 15        Pkt                 169.1250349.1250277.462697.4626 277.462692.0008 268.001079.298    79.298    79.250    2007082910063412                                                  
PUBLT     554_2007            14        Pkt                 15        Pkt                 2         BKL                 97.4626 277.4626254.541074.5410 254.541088.3917 271.204569.455    69.455    69.436    2007082910181512                                                  
PUBLT     554_2007            15        Pkt                 2         BKL                 1         BKL                 74.5410 254.5410253.141073.1410 253.141090.0000 270.00000.000     0.000     0.000     2007082910334814                                                  
PUBLT     554_2007            11        Pkt                 12        Pkt                 16        BKL                 72.5800 252.5800205.122625.1226 205.122690.0517 269.545724.046    24.046    24.046    2007082910523012                                                  
PUBLT     554_2007                                          1         BKL                 2         BKL                 0.0000  0.0000  73.1400 253.140073.1400 90.0000 270.000043.759    43.759    43.759    2007082910523026                                                  
PUBLT     554_2007                                          2         BKL                 1004      BKL                 0.0000  0.0000  73.1320 253.132073.1320 90.0000 270.000015.654    15.654    15.654    2007082910523026                                                  
PUBLT     554_2007                                          1004      BKL                 1005      BKL                 0.0000  0.0000  73.1320 253.132073.1320 90.0000 270.000056.509    56.509    56.509    2007082910523026                                                  
PUBLT     554_2007                                          1005      BKL                 1006      BKL                 0.0000  0.0000  73.1320 253.132073.1320 90.0000 270.000054.130    54.130    54.130    2007082910523026                                                  
PUBLT     554_2007                                          1006      BKL                 1007      BKL                 0.0000  0.0000  168.4420348.4420168.442090.0000 270.000027.970    27.970    27.970    2007082910523026                                                  
PUBLT     554_2007                                          1007      BKL                 1008      BKL                 0.0000  0.0000  166.5200346.5200166.520090.0000 270.00005.137     5.137     5.137     2007082910523026                                                  
PUBLT     554_2007                                          1008      BKL                 1009      BKL                 0.0000  0.0000  166.5200346.5200166.520090.0000 270.000034.039    34.039    34.039    2007082910523026                                                  
PUBLT     554_2007                                          1009      BKL                 1010      BKL                 0.0000  0.0000  166.5200346.5200166.520090.0000 270.000034.055    34.055    34.055    2007082910523026                                                  
PUBLT     554_2007                                          1010      BKL                 16        BKL                 0.0000  0.0000  166.5200346.5200166.520090.0000 270.000034.409    34.409    34.409    2007082910523026

Oh just comment that line out, it tells the debugger to break. I was setting a breakpoint so I could modify the value in field(5) since the sample data I had didn't have a 0.0 value

ok.. its work... thanks a lot bro...
Actually i have another file that want to implement the extracting process like this thread. I have attached that file. The sample of data are as below:
PUBLT 167_89 656 PB -38321.478 6807.984 657 PB DAUD 200005041 278.271074.5150 69.4035 08370074.1830 69.2755 083800254.1925290.4620083900254.5615291.010008400008390098.2710 74.3630 20.3943 278.27100.0211 15.5954 74.3726 278.2748
PUBLT 167_89 656 PB -38321.478 6807.984 657 PB DAUD 200005042 278.271074.4940 68.1425 08430074.1610 68.0010 084400254.1720292.1650084500254.5400292.315508460008450098.2710 74.3418 22.0833 278.27100.0201 15.5958 74.3511 278.2746

what i gonna want to do is to extract those red data and then some simple calculation will be added because there are 2 lines for the same line number such as data for 656-657. The calculation are to get the average from the two values. The sample output are as below:

-this is data extracted for each line
656-657 278.2748
656-657 278.2746
-the final output i want is the average of those two line
656-657 278-27-47

For the calculation, the formula is as below:
278.2748 and 278.2746 are the value for bearing/ azimuth. It means 278 degree 27 minutes 48 seconds. So to get the average value of those two, we must consider the degree, minutes and seconds.
1. convert degree minutes seconds to decimal degrees
278+(27/60)+(48/3600) >>>> result is 278.4633333
278+(27/60)+(46/3600) >>>> result is 278.4627778

2. Convert to radian
278.4633333 x 180 / PI >>>>result is 4.860102013
278.4627778 x 180 / PI >>>>result is 4.860092316

3. get average
(4.860102013 + 4.860092316) / 2 >>>result is 4.860097165

4. Convert back average radian to degrees
4.860097165 x PI / 180 >>>>>>> result is 278.4630556

4. convert back degrees to degree minutes seconds
(for this formula i will create myself...)

the main problem here is i want to use 2 value from 2 line in one time to do that calculation... if those data in one line its not a problem.. how can i possibly do that?

Attachments
PUBLT     167_89              656       PB                  -38321.478  6807.984    657       PB                  DAUD                                                                                                200005041 278.271074.5150 69.4035 08370074.1830 69.2755 083800254.1925290.4620083900254.5615291.010008400008390098.2710 74.3630 20.3943 278.27100.0211  15.5954 74.3726 278.2748
PUBLT     167_89              656       PB                  -38321.478  6807.984    657       PB                  DAUD                                                                                                200005042 278.271074.4940 68.1425 08430074.1610 68.0010 084400254.1720292.1650084500254.5400292.315508460008450098.2710 74.3418 22.0833 278.27100.0201  15.5958 74.3511 278.2746
PUBLT     167_89              348       Pkt                 -41274.383  5533.260    349       PB                  DAUD                                                                                                200002231 269.1220104.032063.1220 084800103.341062.5710 084800283.3740297.1550084900284.1330297.322008490008490089.1220 103.521027.0940 269.12200.0135  -10.0855103.5150269.1146
PUBLT     167_89              348       Pkt                 -41274.383  5533.260    349       PB                  DAUD                                                                                                200002232 269.1220104.205061.4620 085400103.521061.3220 085400283.5920298.5700085500284.3510299.112008550008550089.1220 104.115328.4225 269.12200.0128  -10.0850104.1141269.1154
PUBLT     167_89              484       Pkt                 -42319.149  5583.337    485       PB                  DAUD                                                                                                200003092 101.423098.0830 59.5010 08590097.3500 59.3520 090000277.3650300.3830090100278.1410300.5340090200090100281.423097.5337 30.3140 101.42300.0122  -4.2640 97.5320 101.4158
PUBLT     167_89              484       Pkt                 -42319.149  5583.337    485       PB                  DAUD                                                                                                200003091 101.423097.5045 61.3410 08520097.2025 61.1930 085300277.2155298.5330085400277.5545299.0820085500085400281.423097.3713 28.4702 101.42300.0128  -4.2647 97.3655 101.4158
PUBLT     167_89              89        PB                  -40536.157  7619.924    90        PB                  DAUD                                                                                                200002082 279.0230111.203558.3150 090700110.494558.1650 090700290.5150301.5810090800291.2600302.130009080009080099.0230 111.070331.5038 279.02300.0117  -15.1538111.0745279.0252
PUBLT     167_89              89        PB                  -40536.157  7619.924    90        PB                  DAUD                                                                                                200002081 279.0230110.515060.0110 090100110.220059.4620 090100290.2345300.2840090200290.5755300.433009020009020099.0230 110.385330.2110 279.02300.0122  -15.1543110.3933279.0251
PUBLT     167_89              159       Pkt                 -42699.057  5820.319    160       Pkt                 DAUD                                                                                                200002101 222.5730252.201066.5830 170700251.511067.0355 17070071.5800 292.444517080072.3320 292.354517080017080042.5730 252.104022.4931 222.57300.0157  -14.3106252.0949222.5624
PUBLT     167_89              159       Pkt                 -42699.057  5820.319    160       Pkt                 DAUD                                                                                                200002102 222.5730252.312067.4035 171200252.015067.4425 17120072.0835 291.464017130072.4405 291.401017130017130042.5730 252.212822.0027 222.57300.0202  -14.3102252.2029222.5616
PUBLT     167_89              416       Pkt                 -43081.120  5025.695    417       Pkt                 DAUD                                                                                                200003012 194.2150102.240056.4210 091500101.482056.3450 091500281.5140303.3720091600282.3310303.441009160009160014.2150 102.091733.3107 194.21500.0112  -7.3153 102.0849194.2108
PUBLT     167_89              416       Pkt                 -43081.120  5025.695    417       Pkt                 DAUD                                                                                                200003011 194.2150102.085057.5530 091000101.322557.4810 091000281.3620302.2530091100282.1650302.351009110009110014.2150 101.533632.1915 194.21500.0116  -7.3157 101.5309194.2109
PUBLT     167_89              2         BKL       78/906    -40120.746  10203.556   1         BKL                 DAUD                                                                                                200002022 40.2700 114.104556.4300 091400113.350556.3400 091400293.3825303.3630091500294.1955303.4500091500091500220.2700113.560333.3107 40.2700 0.0112  -17.0324113.565740.2728 
PUBLT     167_89              2         BKL       78/906    -40120.746  10203.556   1         BKL                 DAUD                                                                                                200002021 40.2700 113.441557.5600 090900113.075557.4730 090900293.1145302.2430091000293.5215302.3300091000091000220.2700113.290332.1830 40.2700 0.0116  -17.0327113.296040.2731 
PUBLT     167_89              609       Pkt                 -39643.856  6947.341    610       Pkt                 DAUD                                                                                                200004242 165.202078.0935 68.1110 08440077.3605 67.5650 084500257.3715292.2010084600258.1355292.3510084700084600345.202077.5413 22.1150 165.20200.0201  12.5405 77.5533 165.2123
PUBLT     167_89              609       Pkt                 -39643.856  6947.341    610       Pkt                 DAUD                                                                                                200004241 165.202078.0940 69.3720 08390077.3630 69.2440 084000257.3740290.4940084100258.1350291.0420084200084100345.202077.5425 20.4300 165.20200.0211  12.5401 77.5547 165.2124
PUBLT     167_89              540       Pkt                 -39400.963  6473.620    541       Pkt                 DAUD                                                                                                200003272 304.254089.2730 66.1115 08390088.5235 65.5735 084000268.5210294.1645084100269.2705294.3140084200084100124.254089.0950 24.0954 304.25400.0149  2.3829  89.0929 304.2502
PUBLT     167_89              540       Pkt                 -39400.963  6473.620    541       Pkt                 DAUD                                                                                                200003271 304.254089.2100 67.3815 08330088.4625 67.2410 083400268.4605292.4950083500269.2040293.0435083600083500124.254089.0332 22.4300 304.25400.0157  2.3823  89.0311 304.2502
PUBLT     167_89              207       Pkt                 -43570.486  5306.496    208       Pkt                 DAUD                                                                                                200002142 230.5210253.493067.1020 171400253.214067.1605 17140073.3110 292.130017150074.0800 292.043517150017150050.5210 253.423522.2748 230.52100.0159  -13.1138253.4220230.5141
PUBLT     167_89              207       Pkt                 -43570.486  5306.496    208       Pkt                 DAUD                                                                                                200002141 230.5210253.391066.2555 171100253.112066.3315 17110073.2010 293.134017120073.5630 293.024017120017120050.5210 253.314823.1918 230.52100.0154  -13.1141253.3136230.5145
PUBLT     167_89              111       Pkt                 -40940.003  7012.614    112       Pkt                 DAUD                                                                                                200002082 225.4850251.082064.4425 170600250.383064.5015 17060070.4440 294.385017070071.1950 294.302017070017070045.4850 250.575024.5338 225.48500.0145  -15.0922250.5748225.4830
PUBLT     167_89              111       Pkt                 -40940.003  7012.614    112       Pkt                 DAUD                                                                                                200002081 225.4850251.040063.5230 170100250.323063.5950 17010070.2510 295.465517020070.5020 295.360017020017020045.4850 250.430025.5239 225.48500.0140  -15.0926250.4259225.4831
PUBLT     167_89              695       PB                  -38271.151  7051.168    696       PB                  DAUD                                                                                                200005161 82.3950 71.0450 62.3520 08490070.2840 62.3440 085000250.3030297.4020085100251.1010297.5510085200085100262.395070.4832 27.3622 82.3950 0.0133  19.0740 70.4802 82.3901 
PUBLT     167_89              695       PB                  -38271.151  7051.168    696       PB                  DAUD                                                                                                200005162 82.3950 70.5135 61.0510 08560070.1425 61.5010 085700250.1615299.2450085800251.1605299.3950085900085800262.395070.3935 29.0220 82.3950 0.0127  19.0744 70.3906 82.3902 
PUBLT     167_89              134       Pkt                 -41867.279  6475.067    135       Pkt                 DAUD                                                                                                200002092 204.5840251.410065.2655 171400251.112065.3320 17140071.1710 293.551517150071.5300 293.461017150017150024.5840 251.303824.1017 204.58400.0149  -14.5015251.2956204.5742
PUBLT     167_89              134       Pkt                 -41867.279  6475.067    135       Pkt                 DAUD                                                                                                200002091 204.5840251.234064.2420 170800250.545064.3215 17080071.0100 295.135517090071.3600 295.023017090017090024.5840 251.135225.1957 204.58400.0143  -14.5020251.1308204.5739
PUBLT     167_89              454       PB

Create another thread (the topic has changed) and post the code you have so far. Give this task a shot and we'll use the code you have as a starting point.

Create another thread (the topic has changed) and post the code you have so far. Give this task a shot and we'll use the code you have as a starting point.

sorry.. i dont have any code because i dont know where to start.. because i need to extract 2 lines at a time..
this is the new thread >>> http://www.daniweb.com/forums/post1092890.html#post1092890

Edited 6 Years Ago by wasyazwan: n/a

1st of all try to extract the whole single line and then store it say line then try to extract the position of 4th decimal point(.) and store it a var, let say decpos then using mid function extract ur value i.e. mid(line, decpos+4,8).
Thus you got ur all eight digit.
You need to repeat the above process for each line & then you will get what you want.

May be i am wrong, i thought as per the sample lines given by u.
-Mukesh

Edited 6 Years Ago by __avd: Email Snipped.

This question has already been answered. Start a new discussion instead.