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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:10:18+00:00 2026-05-11T22:10:18+00:00

The below are the set of log data found in text file ********************************************************************************** **2008/04/06**

  • 0

The below are the set of log data found in text file

**********************************************************************************
**2008/04/06** 00:35:35 193111               1008                O          9448050132# 74                               
**2008/04/06** 00:35:35 193116               1009                 O          9448050132# 74                               
 **12/15/2008**   8:36AM 106  01 090788573                             00:01'23" ..06  
**10/10/2008** 14:32:32 4400 4653  00:00:56 26656            0    0           OG AL# 
 &       0000    0000                                      
N 124 00 8630    T001045 **10/16** 05:04 00:01:02 A 34439242360098
***************************************************************************************

I need to extract only date details(may be 200/04/06 or 10/16) from all of the above lines and display it in textbox.

I know how to segregate date if the data is ordered like below

***************************************************************************************
10/10/2008 14:32:32 4400 4653  00:00:56 26656            0    0           OG AL#

10/10/2008 14:33:29 4400 4653  00:00:02 26656434         0    0           OG LL#

10/10/2008 14:33:31 4400 4653  00:00:11 26656434         0    0           OG LL#
***************************************************************************************

The code for it is:

        StreamReader rr = File.OpenText("C:/1.txt");
        string input = null;
        while ((input = rr.ReadLine()) != null)
        {                
            char[] seps = { ' ' };
            string[] sd = input.Split(seps, StringSplitOptions.RemoveEmptyEntries);

            string[] l = new string[1000];

            for (int i = 0; i < sd.Length; i++)
            {
                l[i] = sd[i];
                textBox4.AppendText(l[i] + "\r\n");

                //The date is 10 characters in length. ex:06/08/2008
                if (l[i].Length == 10)                    
                textBox1.AppendText(l[i]+"\r\n");

                //The time is of 8 characters in length. ex:00:04:09
                if (l[i].Length == 8)
                textBox2.AppendText(l[i] + "\r\n");

                //The phone is of 11 characters in length. ex:9480455302#
                if (l[i].Length == 11)
                textBox3.AppendText(l[i] + "\r\n");                    
            }                
         }

Can you please help me with this!!!!

  • 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-11T22:10:18+00:00Added an answer on May 11, 2026 at 10:10 pm

    There are a few oddities in your code. Most notably, the following line inside the while loop:

    string[] l = new string[1000];
    

    This will create a 1000-element string array for each round in the while loop. Later, you will use only element i in that array, leaving the 999 other elements unused. Judging from the rest of the code, you could just as well simply use sd[i].

    Also, I am guessing that textBox1, textBox2 and textBox3 should never contain the same value; if a value goes into one of them, it should never go into another one of them (except textBox4 that seem to collect all data). Then there is also no need to keep testing the value, once the correct textbox is found.

    Finally the following line inside the while loop:

    char[] seps = { ' ' };
    

    This will create an identical character array for each round in the while loop; you can move that outside the loop and just reuse the same array.

    As for the date detection; from the data that you present, the date is the only data that contains a / character, so you could test for that rather than the length.

    You can try the following:

    StreamReader rr = File.OpenText("C:/1.txt");
    string input = null;
    char[] seps = { ' ' };
    while ((input = rr.ReadLine()) != null)
    {    
        string[] sd = input.Split(seps, StringSplitOptions.RemoveEmptyEntries);
        for (int i = 0; i < sd.Length; i++)
        {
            textBox4.AppendText(sd[i] + "\r\n");
    
            if (sd[i].Contains("/"))
            {
                // The string contains a / character; assume it is a date
                textBox1.AppendText(sd[i] + "\r\n");
            }
            else if (sd[i].Length == 8)
            {
                //The time is of 8 characters in length. ex:00:04:09
                textBox2.AppendText(sd[i] + "\r\n");
            }
            else if (sd[i].Length == 11)
            {
                //The phone is of 11 characters in length. ex:9480455302#
                textBox3.AppendText(sd[i] + "\r\n");
            }
        }                
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In below data list represents set of question's and answer, How to check whether
AIM: I would like to set the below function to call every 5 seconds.
I have a question, I have value as below which I set in an
Below is my locale set. LANG=en_US.UTF-8 LC_CTYPE=zh_CN.UTF-8 LC_NUMERIC=en_US.UTF-8 LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_NAME=en_US.UTF-8
I set the logging as below import logging logging.basicConfig( level = logging.DEBUG, format =
I set my embedded bespin as below, which works good: _editorComponent = new bespin.editor.Component('editor',
I have the below command line arguments set for the program. argument proc is
Below is my requirement. @echo off cls Set Sleep=0 :start echo This is a
Hi below link from Vaadin you can see how to set checkboxes on tabletree,
I would like to create set of strings and below is the only limitation.

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.