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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:21:32+00:00 2026-05-17T19:21:32+00:00

I have a text file that is automatically generated by an older computer system

  • 0

I have a text file that is automatically generated by an older computer system daily.

Unfortunately, the columns in this file are not delimited and they are not exactly fixed width (each day the width of each column could change depending on the amount of chars of the data in each column). The file does have column headings, so I want to find the width of each column using the column headings. Here is an example of the column heading row:

JOB_NO[variable amount of white space chars]FILE_NAME[variable amount of ws chars]PROJECT_CODE[variable amount of ws chars][carriage return]

What I want to do is get the index of of the first char in a column and the index of the last white space of a column (from the column heading). I would want to get the index of the “J” in JOB_NUM and the last white space before the “F” in FILE_NAME for the first column.

I guess I should also mention that the columns may not always be in the same order from day to day but they will have the same header names.

Any thoughts about how do do this in VB.net or c#? I know I can use the string.indexOf(“JOB_NO”) to get the index of the start of the column, but how do I get the index of the last white space in each column? (or last whitespace before the next first non-whitespace that denotes the start of the next column)

  • 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-17T19:21:32+00:00Added an answer on May 17, 2026 at 7:21 pm

    Get the indexes of all columns. e.g.

    var jPos = str.IndexOf("JOB_NO");
    var filePos = str.IndexOf("FILE_NAME");
    var projPos = str.IndexOf("PROJECT_CODE");  
    

    Then sort them in an array. from min to max. now you know your columns order. the last space of first column is [the_next_column’s_index]-1.

    int firstColLastSpace = ar[1] -1;
    int secColLastSpace = ar[2] -1;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a text file that gets generated automatically and put in a web
I have a text file that looks like this. A 102 B 456 C
I have Text file that contains data separated with a comma , . How
I have a text file that I want to edit by rewriting it to
I have a text file that's appended to over time and periodically I want
I have a text file that contains cached data in JSON format. I'm trying
I have a text file that contains some strings separated by ,. Strings are
I have a text file that I want to edit using Java. It has
I have a text file that contains a list of filenames, minus the extension,
I have a text file that looks a bit like: random text random text,

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.