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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T05:51:39+00:00 2026-05-25T05:51:39+00:00

I’ve got a Comma Delimited Text file that I am trying to read in.

  • 0

I’ve got a Comma Delimited Text file that I am trying to read in.

I read in 1 line at a time, and process that information.

Using the code snippet and file fragment below, my error comes when I get to the line that starts with 841 – it only pulls in 147 characters.

Question: What is causing the TextReader to stop pulling in this line? Is there some special sequence in it?

Code Snippet:

int lastNum = -1;
int num = 1;
using (TextReader reader = File.OpenText(filename)) {
  do {
    string line = reader.ReadLine();
    if (!String.IsNullOrEmpty(line)) {
      string[] split = line.Split(',');
      int indexer = Convert.ToInt32(split[0]);
      Console.WriteLine("#{0}: ID '{1}' Line Length = {2}", num++, split[0], line.Length);
    }
  } while ((-1 < reader.Peek());
  reader.Close();
}

File Fragment (from line 0 to ProblemLine + 1):

ID,Line,[Date],WO,Module,DSO,Integer,Unit,,Contact,Category,Problem,Solution,Action,Actor,Acted
824,,1/4/2011,589259,,170966,JC,V3A,,Tom Read,WO.3,"The unit is stainless steel, but the coil connection plates that were on the work order were not stainless steel",MTF # 264698 to take off CC500 AND CC875 and added XCC500 AND XCC875,,,
825,,1/4/2011,588779,,171102,JC,V3A,,,W.4,Changing from a 310AJ motor to a 310AX,MTF # 46746 to fan assembly and motor,,,
826,,1/4/2011,588948,,170941,JC,V3B,,,W.4,Changing from a 310AJ motor to a 310AX,MTF # 241092 and 241093 to change fan assemly and EBM motor,,,
827,,1/4/2011,588206,,171143,JC,H3A,,,WO.2,Potentiometer was missing from the work order,MTF # 264851 to add 29278,,,
828,,1/4/2011,584741 584742 584748 584747 584749,,171009,BF,V2B,,"Carlos, Laura",,Johnson units. Motors would not fit correctly using the motor mounts already installed.,MTF# S264510 to remove 006-300 motor mounts from work orders. MTF# S264699 to add 006-033 motor mounts to work orders.,,,
829,,1/4/2011,586519,,170891-1-2,DB,H3B,,"Carlos, Laura",WO.2,"1"" bushing not on BOM.",MTF# 264769 added 28614,,,
830,,1/4/2011,583814,,170804-1-3,DB,V3B,,"Carlos, Laura",WO.3,Wrong pulley (26710) and wrong Belt A-41 (29725) appear on WO.,MTF# 264570 removed those and put on an A-33 (26768) and pulley 27005. Two units so Qty 2 for each item.,,,
831,,1/5/2011,584742,,171009,JC,V2B,,,,there was an extra overload relay on the work order because it had been changed and the original was never taken off.,MTF # 241926 to take off 7- 27167 overload relay,,,
832,,1/5/2011,591742,,170965,JC,H3C,,"Carlos, Laura",WO.3,Belt was too short,MTF # 241729 to take off 30737 (BX42) and put on 28589 (BX52). Center to center distance was 19 3/8 in,,,
833,,1/5/2011,584749,,171009,JC,H2A,,Joe ,E.3,Did a motor change in order for the motor to work on the unit,MTF # 264854 to add 28918 and take off 28095 motor and SP01204 pulley,,,
834,,1/5/2011,588945,,171157,JC,V3B,,Alex,D,Stainless steel unit needed a stainless steel power entering cover plate.,Spoke with Alex and he designed X302-905 and MTF # 241094  was done to add to this work order.,,,
835,,1/5/2011,589259,,170966,JC,V3A,,Alex,D,Stainless steel unit needed a stainless steel power entering cover plate.,Spoke with Alex and he designed X302-905 and MTF # 241094  was done to add to this work order.,,,
836,,1/5/2011,584749,,171009,JC,H2A,,,,Changed overload relay because changed motor,MTF # 264857 to change overload relay. Took off 27169 and added 26736,,,
837,,1/6/2011,583815,,170804,JC,V3B,,"Carlos, Laura",WO.3,bore hole on the pulley was too big ,MTF # 241096  to take off 26710 7/8 pull and put on 27005 5/8 pulley,,,
838,,1/6/2011,583816,,170804,JC,V3B,,"Carlos, Laura",WO.3,bore hole on the pulley was too big ,MTF #  241096 to take off 26710 7/8 pull and put on 27005 5/8 pulley,,,
839,,1/6/2011,587632,,171143,BF,M2,,"Carlos, Laura",WO.2,H302-850 blank off #3 not on WO.,MTF# S242648 to add (1) H302-850,,,
840,,1/6/2011,583816,,170804,BF,M2,,"Carlos, Laura",WO.3,A41 Belt too large,"MTF# S241706 to remove A41 (29725) and add A33 (26780). C-C distance 12.5",,,
841,,1/7/2011,588945,,171157,JC,V3B,,Tom Read ,D,"Assembly drawing AD-V3B-162C-EPSSTLDR had a 7/8 distributor connecting to a 5/8 opening on a tee.

“,MTF # 264653 to to add bushing 27256 and 28997 tee in order to use a tee that would fit into the distributor.,,,

842,,1/7/2011,589257,,170966,JC,V3C,,Everyone ,WO.2,heat exchanger was missing from the work order ,MTF # 264858 to add the heat exchanger on work order and one was ordered.,,,

LOOK! ^^^ S.O.’s reader did it too!

Here is the exact text of the line that starts with 841:

841,,1/7/2011,588945,,171157,JC,V3B,,Tom Read ,D,”Assembly drawing AD-V3B-162C-EPSSTLDR had a 7/8 distributor connecting to a 5/8 opening on a tee.
“,MTF # 264653 to to add bushing 27256 and 28997 tee in order to use a tee that would fit into the distributor.,,,

FYI: I am developing in C# against .NET Framework 4.

[Solved] I was able to figure this out using Rob Parker‘s comment and using a raw Stream instead of the prettier TextReader class. It turns out my Rogue character was an inserted Carriage Return (\n).

using (Stream fs = File.Open(filename, FileMode.Open, FileAccess.Read)) {
  byte[] data = new byte[1024];
  int len;
  do {
    len = fs.Read(data, 0, data.Length);
    for (int n = 0; n < len; n++) {
     if ((n + 3) < len) {
        string strId = string.Format("{0}{1}{2}", (char)data[n + 1], (char)data[n + 2], (char)data[n + 3]);
        int numeric = Convert.ToInt32(strId);
        if (numeric == 841) {
          char[] suspects = new char[50];
          int n2 = n;
          int n3 = 0;
          while (n2 < len) {
            if ((n + 130 < n2) && (n2 < n + 160)) {
              suspects[n3++] = (char)data[n2];
            }
            n2++;
          }
          Console.WriteLine("Wait Here!");
          break;
        }
      }
    }
    num++;
  } while (0 < len);
}

Thanks everyone for your help!

  • 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-25T05:51:40+00:00Added an answer on May 25, 2026 at 5:51 am

    Since it turned out to be particularly helpful…

    Have you checked what character(s) there are between the period and doublequote character at the point where it’s splitting the line?

    If ReadLine() doesn’t include the line-break characters in what it returns you might have to do a little work to get to it/them. But if you can get the FileStream object used by the TextReader (not sure if it’s exposed) you could add code to detect the problem line (starting “841,”) and hit a breakpoint (or Debugger.Break()) and then use the underlying FileStream to back up the Position and read the raw bytes to see what’s there.

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have thousands of HTML files to process using Groovy/Java and I need to
I have a reasonable size flat file database of text documents mostly saved in
I'm trying to create an if statement in PHP that prevents a single post
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have just tried to save a simple *.rtf file with some websites and

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.