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 204703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:29:29+00:00 2026-05-11T17:29:29+00:00

I have a tab delimited text file as so : name \t loan period

  • 0

I have a tab delimited text file as so :

name    \t loan period \t loan amount
John    \t 5 years     \t 6000
Sarah   \t 5 years     \t 6000
Jane    \t 1 month     \t 100

I’m looking to copy the lines where “loan period” = “5 years” to where “loan period” = “1 month”, in order to show the comparison. The new lines would be appended at the end of the resulting file.

The ultimate end result I hope to achieve is this :

name    \t loan period \t loan amount
John    \t 5 years     \t 6000
Sarah   \t 5 years     \t 6000
Jane    \t 1 month     \t 100
John    \t 1 month     \t 100
Sarah   \t 1 month     \t 100

I’ve been toying about this with Visual Basic .Net, and so far, this is what I’ve come up with

    Dim strData As String
    Dim i As Short
    Dim strLine() As String
    lngSize = 0

FileOpen(1, txtloanlistinput.Text, OpenMode.Input)
    While Not EOF(1)
        i = i + 1
        strData = LineInput(1)
    End While
    FileClose(1)
    ReDim loanlist(i)
    strData = ""
    lngSize = i
    i = 0
    FileOpen(2, txtloanlistinput.Text, OpenMode.Input)
    While Not EOF(2)
        i = i + 1
        strData = LineInput(2)
        If i = 1 Then
            strData = LineInput(2)
        End If
        strLine = Split(strData, Chr(9))
        loanlist(i).strName = strLine(0)
        loanlist(i).strLoanPeriod = strLine(1)
        loanlist(i).curLoanAmount = strLine(2)
    End While
    FileClose(1)
    FileClose(2)

I’m drawing a blank as to how to proceed, and thought I’d ask for 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-05-11T17:29:29+00:00Added an answer on May 11, 2026 at 5:29 pm

    A litle ugly but is a start.

    //c#

            OpenFileDialog dialog = new OpenFileDialog();            
            dialog.ShowDialog();            
            string filePath = dialog.FileName;
            //in this list we store the match of 5 years.
            List<string[]> fiveYears = new List<string[]>();
            //open a reader.
            StreamReader tr = new StreamReader(filePath);
            //reaing 1° line.
            string line=tr.ReadLine();
            while (line != null && line != "" && line != "\n")
            {
                //split de line by tabs.
                string[] lineByTabs = line.Split('\t');
               //if the second term equals '5 years'
                if (lineByTabs[1].Equals("5 years"))
                {
                    //change from  5 years to 1 month, and to a lonan of 100.
                    lineByTabs[1] = "1 month";
                    lineByTabs[2] = "100";
                    fiveYears.Add(lineByTabs);                   
                }
                line = tr.ReadLine();
            }
            //close reader
            tr.Close();
            //open the file and apend lines.
            TextWriter tw = new StreamWriter(filePath, true);
    
            foreach (string[] lines in fiveYears)
            {
                tw.WriteLine(lines[0] + "\t" + lines[1] + "\t" + lines[2]);
            }
            tw.Close();
    
        }
    

    ‘vb.net

        Dim dialog As OpenFileDialog = New OpenFileDialog
        Dim filePath, line As String
        Dim fiveYears As List(Of String()) = New List(Of String())
        Dim lineByTabs As String()
        Dim tr As StreamReader
        Dim tw As TextWriter
        dialog.ShowDialog()
        filePath = dialog.FileName
    
        tr = New StreamReader(filePath)
    
        line = tr.ReadLine()
    
        While Not line = ""
    
            lineByTabs = line.Split(vbTab)
    
            If lineByTabs(1).Equals("5 years") Then
    
                lineByTabs(1) = "1 month"
                lineByTabs(2) = "100"
                fiveYears.Add(lineByTabs)
            End If
            line = tr.ReadLine()
        End While
    
        tr.Close()
    
        tw = New StreamWriter(filePath, True)
    
        For Each lines As String() In fiveYears
            tw.WriteLine(lines(0) + vbTab + lines(1) + vbTab + lines(2))
        Next
        tw.Close()
    

    hope it helps

    note: flie has to end in a new line. and folows the given format (3 colums).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a tab delimited text file with the following data: ahi1 b/se ahi
I have a text file with tab delimited data spread across 16 columns. I
I have a 2GB big text file, it has 5 columns delimited by tab.
I have a malformed tab delimited csv file Name AA BB CC AA BB
I have to parse a tab-delimited text file with Ruby to extract some data
I have a text file that is tab-delimited. How can I separate this string
I have a text file that is tab delimited and looks like: 1_0 NP_045689
I read in a text file that is tab delimited, i then have a
I have a tab-delimited text file that I am parsing. Its first column contains
I have a tab delimited text file with the first row being label headings

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.