Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8543193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:14:41+00:00 2026-06-11T12:14:41+00:00

I am trying to create a converter to read a very long text file

  • 0

I am trying to create a converter to read a very long text file looking for a line that contains a certain string. When it finds this string it should write the line it found to a new file along with other lines before and after.

My application works but is only repeating the first found line in all the groups of lines it creates.

For example, a group in the old file looks like this:

[PARTICLE930]
INDEX = 930              ;º§¶óÅä076_¼ÕµîÀÌÆåÆ®_¿À¸¥
ABSAXIS=0 
PARTICLE=.\Chef\60LV_WHITE\B\BF\076\hand_eff_r.spt

I want to extract just the line beginning with PARTICLE=.\ and create the new lines around it automatically. Because the group numbers are sequential and don’t have gaps, I don’t need to extract the index number, I can create it on the fly.

My code so far:

Dim source As String = "Particle.ini"
Dim dest As String = "CParticle.ini"
Dim path As String = Application.StartupPath
Dim max As Integer = 1233

Dim l_pnum As String = "[PARTICLE{0}]"
Dim l_index As String = "INDEX = {1}"
Dim l_absaxis As String = "ABSAXIS=0"
Dim l_particle As String = "{2}"


If System.IO.File.Exists(path & "\" & source) Then
    Dim objReader As New System.IO.StreamReader(path & "\" & source)
    Dim objWriter As New System.IO.StreamWriter(path & "\" & dest, True)

    objWriter.WriteLine("[PARTICLE_INFO]")
    objWriter.WriteLine("MAXPARTICLE=" & max.ToString)

    Dim loop_num As Integer = 1
    Do While objReader.Peek() <> -1

        Dim line_read As String = objReader.ReadLine()

        If line_read.Contains("PARTICLE=.\") Then

            l_pnum = l_pnum.Replace("{0}", loop_num.ToString)
            l_index = l_index.Replace("{1}", loop_num.ToString)
            l_particle = l_particle.Replace("{2}", line_read)

            objWriter.WriteLine(l_pnum)
            objWriter.WriteLine(l_index)
            objWriter.WriteLine(l_absaxis)
            objWriter.WriteLine(l_particle)

            loop_num = loop_num + 1
        End If

    Loop

Else
    MessageBox.Show("File does not exist" & vbNewLine & path & "\" & source)
End If

As I said above, it works but it’s just repeating index 1 over and over for as many times as there are groups to convert.
Effectively all I want to do is remove all the white gaps, and the foreign characters from the file while retaining it’s structure.

I’m not sure what I’ve done wrong here. Anyone able to help?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T12:14:42+00:00Added an answer on June 11, 2026 at 12:14 pm

    It looks like you are wiping out your formatting on your first replace, therefore it never writes the next record.

    You setup your Strings as such:

    Dim l_pnum As String = "[PARTICLE{0}]" 
    Dim l_index As String = "INDEX = {1}" 
    Dim l_absaxis As String = "ABSAXIS=0" 
    Dim l_particle As String = "{2}" 
    

    Then when you write your first record you replace your master with your results meaning you no longer have the formatting to write out the next record.

    l_pnum = l_pnum.Replace("{0}", loop_num.ToString)  
    l_index = l_index.Replace("{1}", loop_num.ToString)  
    l_particle = l_particle.Replace("{2}", line_read)  
    

    Either create temporary variables to hold your results or use the result without assigning it to your initial string.

    i.e.

    objWriter.WriteLine(l_pnum.Replace("{0}", loop_num.ToString))      
    objWriter.WriteLine(l_index.Replace("{1}", loop_num.ToString))      
    objWriter.WriteLine(l_absaxis)      
    objWriter.WriteLine(l_particle.Replace("{2}", line_read))  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a style that will attach a Converter to it so
I'm trying to create a shell script that shall convert certain Files according to
In ASP.Net (with C#) I'm trying to create a .DAT file with plain text
I'm trying to create a very simple stand-alone app that converts CATIA .dat files
I'm trying to create a function to read Morse code from one file, convert
I'm trying create simple application in C++. This application has to read from file
Hi I'm trying to create a converter to Convert my images in a database
I'm trying to create a control that converts the page it's on into a
I'm trying to read a binary file (which represents a matrix in Matlab) in
Im trying to get this remote binary file to read the bytes, which (of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.