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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:22:01+00:00 2026-06-06T13:22:01+00:00

I am working on a script that converts a .txt file (non delimited) to

  • 0

I am working on a script that converts a .txt file (non delimited) to an Excel spreadsheet. My problem occurs where I need to pull data that could be between 5-10 characters and there are several sets of data on each line.

Each line can have the following number of characters in each field and there are five fields to pull in each line:

10 char    10 char   10 char  17 char           10 char

523452    D918      20120418  1FD7X2XTACEB8963820120606  
523874    L9117244  20120409  3C6TDT5H0CG12130200000000
535581    G700      20120507  5GYFUD CT        00000000

I basically need to be able to pull 10,10,10,17,10 and place them in their own cell in a row in Excel. I am able to pull the cells as it is now but its based on space delimitation and that causes a problem when the fields don’t take up the full amount of space and I end up with an Excel sheet with blank cells in it.

  • 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-06T13:22:02+00:00Added an answer on June 6, 2026 at 1:22 pm

    You can use String.Substring (your tag reads C#):

    using System;
    using System.IO;
    
    class Test 
    {
      public static void Main() 
      {
         try 
         {
            // Create an instance of StreamReader to read from a file.
            // The using statement also closes the StreamReader.
            using (StreamReader sr = new StreamReader("TestFile.txt")) 
            {
                String line;
                // Read and display lines from the file until the end of 
                // the file is reached.
                while ((line = sr.ReadLine()) != null) 
                {
                    String Chunk1 = line.Substring( 0, 10);  // First 10
                    String Chunk2 = line.Substring(10, 10);  // Second 10
                    String Chunk3 = line.Substring(20, 10);  // Third 10
                    String Chunk4 = line.Substring(30, 17);  // Now 17
                    String Chunk5 = line.Substring(47);      // Remainder (correction: Chunk2 --> Chunk5)
                    Console.WriteLine("Chunks 1: {0} 2: {1} 3: {2} 4: {3} 5: {4})",
                         Chunk1, Chunk2, Chunk3, Chunk4, Chunk5);
    
                }
                Console.ReadLine();
            }
         }
         catch (Exception e) 
         {
            // Let the user know what went wrong.
            Console.WriteLine("The file could not be read:");
            Console.WriteLine(e.Message);
         }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a script that generate some Excel documents and I need to
I'm currently working on a problem that basically involves processing all data in a
Im working on a script that needs to find a match for certain letters(chords)
I'm working with a script that is calling the same class twice and throwing
I'm working on a script that will check if a user is an Administrator
I am working on a script that will scroll through list elements by clicking
I am working on php script that may involve a long running task. The
i'm working on a script that will monitor traffic on specific hosts from nagios.
I'm working on a script that is supposed to install some software from a
I was working on a script that grabs the value from the selected option

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.