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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:03:45+00:00 2026-05-23T17:03:45+00:00

I’m writing an automation program to parse a tab-delimited file and write the data

  • 0

I’m writing an automation program to parse a tab-delimited file and write the data into another program. Currently it takes each line of the file, splits it by tab, and uses the different entries in it’s commands. My issues is that even though all the data entries I am parsing should have ‘X’ amount of fields, there are a good number of fields that are just empty, and sometimes there are tabs that will immediately succeed other tabs.

When I try and access the list of strings from the split file-line, I find myself sometimes getting an IndexOutOfRangeException quite frequently. Would the multiple tabs be causing my list to not always end up with ‘X’ amount of fields, and therefore throw this exception? If so, is there a way around this?

[EDIT]
Heres the code:

string[] parts = line.Split('\t');
String Organization = parts[0];
String SalesRep_FirstName = SalesRep.Split(' ').First();
String SalesRep_LastName = SalesRep.Split(' ').Last();
String Opportunity = parts[1] == "" ? "" : parts[1];
String Type = parts[6] == "" ? comboBox1.SelectedItem.ToString() : parts[6];
String CloseMonth = (parts[5].Split('/'))[0] == "" ? "12" : (parts[5].Split('/'))[0];
String CloseDay = (parts[5].Split('/'))[1] == "" ? "21" : (parts[5].Split('/'))[1];
String CloseYear = (parts[5].Split('/'))[2] == "" ? "2012" : (parts[5].Split('/'))[2];
String Stage = (parts[2].Split('-'))[0] == "" ? "1" : (parts[2].Split('-'))[0];
String Probability = parts[4] == "" ? "0" : (Math.Round(decimal.Parse(parts[4]) / 10) * 10).ToString();
String Source = parts[7] == "" ? "" : parts[7];
String Department = Type;
String Product = Opportunity;
String Revenue = parts[3] == "" ? "" : parts[3];

Ideally, each instance of the list parts will have 9 entries, (parts[8] is redundant, so its not referenced here)

  • 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-23T17:03:46+00:00Added an answer on May 23, 2026 at 5:03 pm

    That shouldn’t be the problem, unless you’re using StringSplitOptions.RemoveEmptyEntries.

    For example:

    string text = "a\t\t\tb";
    string[] bits = text.Split('\t');
    Console.WriteLine(bits.Length); // 4, of which the middle two are empty
    

    If you can post the code which isn’t working (in a short but complete form, ideally) that would help.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I am currently running into a problem where an element is coming back from
i want to parse a xhtml file and display in UITableView. what is the
I have just tried to save a simple *.rtf file with some websites and
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

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.