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

  • Home
  • SEARCH
  • 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 593119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:48:42+00:00 2026-05-13T15:48:42+00:00

var t1 = from line in File.ReadAllLines(@alkahf.txt) let item = line.Split(new string[] {. },

  • 0
var t1 = from line in File.ReadAllLines(@"alkahf.txt")
                     let item = line.Split(new string[] {". "}, StringSplitOptions.RemoveEmptyEntries)
                     let verse = line.Split(new string[] { "\n. " }, StringSplitOptions.RemoveEmptyEntries)
                     select new
                     {
                         Index = item,
                         Text = verse
                     };

having problems with above code im unsure how to parse the lines properly.

the format of the file is like so, I would also like to ignore any empty lines
StringSplitOptions.RemoveEmptyEntries doesn’t work for some reason

1. This is text it might have numbers

2. I skipped a line
  • 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-13T15:48:42+00:00Added an answer on May 13, 2026 at 3:48 pm

    In the LINQ part, you are inside a single line, so you might want to exclude the empty lines first:

    from line in File.ReadAllLines(@"alkahf.txt")
    where !string.IsNullOrEmpty(line)
    

    You then do two splits – one on newline, which is odd (since that won’t be there, since we know we are reading lines). I expect you mean something like:

    let parts = line.Split('.')
    where parts.Length == 2
    select new {
        Index = parts[0],
        Text = parts[1]
    };
    

    ?

    Also, note that ReadAllLines is a buffered operation; if you want true streaming, you might want something like:

    public static IEnumerable<string> ReadLines(string path) {
        using(var reader = File.OpenText(path)) {
            string line;
            while((line = reader.ReadLine()) != null) {
                yield return line;
            }
        }
    }
    

    which is not buffering (you don’t load the entire file at once). Just change the first line to:

    from line in ReadLines(@"alkahf.txt")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The task is to convert the CSV file into XML. var x = from
hi have in file the example line: (in file) PATH: word1 /var/tmp word2 word3
This is my function: private IEnumerable<string> SeachItem(int[] ItemIds) { using (var reader = File.OpenText(Application.StartupPath
i want to delete something from each line of file for example :- i
This query works great: var pageObject = (from op in db.ObjectPermissions join pg in
If I have something like: var query = from children in _data.Children where children.ChildId
I have a Linq to objects statement var confirm = from l in lines.Lines
My code for sql connection using linq is: var query1 = from u in
How to implement method for IQuariable like below: var trash = (from a in
Is is better to do a joined query like this: var employer = (from

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.