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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:35:15+00:00 2026-06-04T13:35:15+00:00

A tab delimited txt file is being read line by line into a list

  • 0

A tab delimited txt file is being read line by line into a list of strings. the aim is to process each word of the string with the format type of the string like datetime or, float or string of characters etc.? so that the data can be plotted . Is there any other efficient way to do this?

 using (StreamReader file = new StreamReader(@"C:\Users\\Desktop\snpprivatesellerlist.txt"))
 {
   while ((line = file.ReadLine()) != null)
   {
     char[] delimiters = new char[] { '\n' };
     string[] parts = line.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
     for (int i = 0; i < parts.Length; i++)
     {
       st = parts[i];

       // process the line - if part[i] is date time - do something ()
       //                      if part[i] is a float - do something else()

     }
   }
 }

Any help and insight is appreciated.
Thanks.

  • 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-04T13:35:16+00:00Added an answer on June 4, 2026 at 1:35 pm

    The code that kinda solved my issue – but i am still working it.

        using (StreamReader file = new StreamReader(@"C:\Users\Desktop\snpprivatesellerlist.txt"))
            {
                while ((line = file.ReadLine()) != null)
                {
                    char[] delimiter1 = new char[] { '\n' };
                    string[] part1 = line.Split(delimiter1, StringSplitOptions.RemoveEmptyEntries);
    
                    for (int i = 0; i < part1.Length; i++)
                    {
                        sepList.Add(part1[i]);     
                        //st = part1[i];                       
                    }
    
                }
                file.Close();
            }
    
            char[] delimiter2 = new char[] { '\t' };
            for (int j = 4; j < sepList.Count; j++)
            {
                st = sepList[j];
                string[] part2 = st.Split(delimiter2, StringSplitOptions.RemoveEmptyEntries);
                alist.Add(part2);             
            }
    
            //DateTime time = new DateTime();
            //float value = new float();
    
            string tagname = alist[0][0];
            for (int y = 0; y < alist.Count; y++)
            {
                 if (alist[y][0]==tagname)
                {
                          alist1.Add(alist[y]);
                }
                 else
                 {
                    SensorProbeDataContainer sensorprobe = new SensorProbeDataContainer();
                    sensorprobe.Setdata(templist);                   
                    sensorprobe.SensorProbe = sensorprobe.data[0][0];
                    ProbeList.Add(sensorprobe.SensorProbe);
                    DateTime.TryParse(sensorprobe.data[0][2], out sensorprobe.StartDate);
                    DateTime.TryParse(sensorprobe.data[(sensorprobe.data.Count - 1)][2], out sensorprobe.EndDate);
                    classcontainer.Add(sensorprobe);
                    tagname = alist[y][0];
                    templist.Clear();                 }
    
            }
    

    I am trying to follow it on this thread – https://stackoverflow.com/questions/10719396/iterating-separating-list-of-string-arrays-based-on-first-element

    Thanks all for the help. Please do point out if you spot any mistakes in code.

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

Sidebar

Related Questions

I need to read test.TXT file(tab delimited) into MATLAB. TXT file have form: Datum
Basically I have converted a tab delimited txt file into a list containing a
I am using TextReader to read in each line of a tab delimited file.
I'm having some problem writing a tab delimited string into a txt file. //This
I have a tab-delimited text file. I have split this into columns. Each of
I'm trying to export an Excel database into .txt (Tab Delimited), but some of
After spliting a tab delimited file I have my required values in a string
I have a .txt file with the following data: sampleF.txt --> (tab delimited) MSFT
The file which I am processing (param.txt) is tab delimited and the contents of
I'm trying to get a TAB-delimited ( tsv ) file loaded into a pandas

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.