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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T09:17:25+00:00 2026-06-02T09:17:25+00:00

I have a file which has temperature data in it . I need to

  • 0

I have a file which has temperature data in it . I need to extract temperature from it and save the result with only temperatures in a new file.

This is the contents of the file :

BCAST:000D6F00017620E9, 02=34.23
BCAST:000D6F00017620E9, 02=12.3
BCAST:000D6F00017620E9, 02=54.01
BCAST:000D6F00017620E9, 02=12.34
BCAST:000D6F00017620E9, 02=16.22

Need to extract the data after every = i.e 34.23,12.3,54.01 etc

I have tried using sub string but it can be used when i read the file as a string and it just makes a substring of first line , rest remains same.Following is my code.Please suggest !

string temp2 = System.IO.File.ReadAllText(@"C:********\temperature.txt");
int c = temp2.IndexOf("=");
string temp3 = temp2.Substring(c + 1);
System.IO.File.WriteAllText(@"C:\*******\temperature2.txt",temp3);

Output of this code is :

34.23
BCAST:000D6F00017620E9, 02=12
BCAST:000D6F00017620E9, 02=54
BCAST:000D6F00017620E9, 02=12
BCAST:000D6F00017620E9, 02=16
  • 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-02T09:17:27+00:00Added an answer on June 2, 2026 at 9:17 am

    ReadAllText will return the entire file as one string. It would make more sense to loop on an array of lines and use your substring code on each line.

    EDIT ReadAllLines is a static call:

    string[] lines = System.IO.File.ReadAllLines(fileName);
    

    Or, read one line at a time with a stream:

    var sr = new StreamReader(fileStream);
    while (!sr.EndOfStream)
    {
      var line = sr.ReadLine();
      // .. per line sub string
    }
    

    EDIT 2 I worked out a complete solution (note I prefer stream reading as opposed to read-all styles – it is more efficient for very large files – so it’s a good practice to get used to)

    var sb = new StringBuilder();
    
    using (var file = new FileStream("C:/tmp/temps.txt", FileMode.Open, FileAccess.Read))
    {
      var sr = new StreamReader(file);
    
      while (!sr.EndOfStream)
      {
        var nextLine = sr.ReadLine();
        int indexOfEqualSign = nextLine.IndexOf("=");
    
        if (indexOfEqualSign == -1 || indexOfEqualSign == nextLine.Length)
          continue;
    
        string rightHandSide = nextLine.Substring(indexOfEqualSign + 1);
        sb.AppendLine(rightHandSide);
      }
    }
    
    File.WriteAllText("C:/tmp/temps2.txt", sb.ToString());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Excel file (which has data imported from Oracle 10G Database) one
I have a file which has text like this: #1#14#ADEADE#CAH0F#0#0..... I need to create
I have a php file which has a require_once Statement (?) this file is
I have progress.js file which has the following code $('#text_area_input').keyup(function() { var text_area_box =$(this).val();//Get
I have a very large XML file which has like 40000 data, and when
I have a file which has data in the following format A B -----
I have a JavaScript file which has a hard coded BASEURL variable, this value
I have my template file which has data being populated into it. However I
I have a file which has a list of library I need for a
I have a file which has contents on every line following this format (A,

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.