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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:39:37+00:00 2026-05-24T00:39:37+00:00

I am trying to retrieve data from a file to change it and replace

  • 0

I am trying to retrieve data from a file to change it and replace the old data.

I have a file that looks something like this:

TEXT  NEXT_TEXT  10.505   -174.994 0  
TEXT  NEXT_TEXT  100.005  174.994  90  
TEXT  NEXT_TEXT  -10.000  -5.555   180  
TEXT  NEXT_TEXT  -500.987 5.123    270  
TEXT  NEXT_TEXT  987.123  1.000    180  
TEXT  NEXT_TEXT  234.567  200.999  90 

I am trying to grab the 3rd and 4th columns to change the data based on what a user inputs into two TextBoxes. Let’s label the 3rd column “X” and the 4th column “Y”. With this, there are also two TextBoxes labeled “xTextBox” and “yTextBox”. These textboxes allow the user to enter in numbers and the number they enter in (postive, negative, and/or a decimal up to 3 decimal places) for each textbox (X and Y) will be ADDED to the “X” column values and the “Y” column values.

Right now, I am using this CODE (below) to strip the “X” and “Y” columns and display their values into different RichTextBoxes labeled xRichTextBox and yRichTextBox.

So, the xRichTextBox looks like this:

10.505
100.005
-10.000
-500.987
987.123
234.567

and the yRichTextBox looks like this:

-174.994
174.994
-5.555
5-123
1.000
200.999

CODE:

    private void calculateXAndYPlacementTwo()
    {
        // Reads the lines in the file to format.
        var fileReader = File.OpenText(filePath);

        // Creates a list for the lines to be stored in.
        var fileList = new List<string>();

        // Adds each line in the file to the list.
        while (true)
        {
            var line = fileReader.ReadLine();
            if (line == null)
                break;
            fileList.Add(line);
        }

        // Creates new lists to hold certain matches for each list.
        var xyResult = new List<string>();
        var xResult = new List<string>();
        var yResult = new List<string>();

        // Iterate over each line in the file and extract the x and y values
        fileList.ForEach(line =>
        {
            Match xyMatch = Regex.Match(line, @"(?<x>-?\d+\.\d+)\s+(?<y>-?\d+\.\d+)");
            if (xyMatch.Success)
            {
                // grab the x and y values from the regular expression match
                String xValue = xyMatch.Groups["x"].Value;
                String yValue = xyMatch.Groups["y"].Value;

                // add these two values, separated by a space, to the "xyResult" list.
                xyResult.Add(String.Join(" ", new[]{ xValue, yValue }));

                // Adds the values into the xResult and yResult lists.
                xResult.Add(xValue);
                yResult.Add(yValue);

                // Place the 'X' and 'Y' values into the proper RTB.
                xRichTextBox.AppendText(xValue + "\n");
                yRichTextBox.AppendText(yValue + "\n");
            }
        });
    }

SO for example if the user enters in “10.005” for the xTextBox and “-20” for the yTextBox the updated xRichTextBox would look like this:

20.510
110.010
0.005
-490.982
997.128
224.572

and the updated yRichTextBox would look like this:

-194.994
154.994
-25.555
-14.877
-19.000
180.999

After this takes place, I am trying to replace the 3rd and 4th columns of the original file with the updated values.

  • I am currently getting the values (“X” and “Y”) in the file and outputting them to seperate RichTextBoxes, but I do not know how to add these values to the values entered in from each TextBox… How can I do this?
  • After the RichTextBox values are calculated with the ‘TextBox` values, how can I take these new values and add them to the original file?

**These values are not always the same or else I would hardcode them in.


So, the new file would look like this:

TEXT  NEXT_TEXT  20.510   -194.994 0  
TEXT  NEXT_TEXT  110.010  154.994  90  
TEXT  NEXT_TEXT  0.005    -25.555  180  
TEXT  NEXT_TEXT  -490.982 -14.877  270  
TEXT  NEXT_TEXT  997.128  -19.000  180  
TEXT  NEXT_TEXT  224.572  180.999  90 
  • 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-24T00:39:39+00:00Added an answer on May 24, 2026 at 12:39 am

    You know how to read the files, but it sounds as though you’re just putting them straight into the textboxes. I would create an object to represent a line (with an x, y, and whatever the last column is). When you read them in, create a list of the objects. To display them, loop through and select each x (can easily be done with linq if you’re using 4.0) and each y for the separate ones. To update, loop through and add the appropriate number to each object. Then to save, just write out each object again.

    Edit: After looking more carefully at your code, you’re keeping a list of the Xs, and a list of the Ys. Create the object I mentioned and only keep a list of those.

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

Sidebar

Related Questions

I have a model that I'm trying to retrieve an array of data from,
I'm trying to retrieve data from a php file named return that just contains
I am trying to retrieve particular data from a txt file and would like
I am trying to use a textreader to retrieve data from a text file
I am trying to retrieve JSON data from an external text file using a
I am trying to retrieve the text data from an ePub file using Java.
I am using liferay technology and trying to retrieve data from xml file in
I'm trying to retrieve link text from an HTML file. Each of the link
I am trying retrieve data from a .php file on a server from within
I 'm trying to retrieve data from a datastore by using this (in example)

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.