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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:10:04+00:00 2026-05-20T15:10:04+00:00

I’m having difficulty combining some lines in a comma delimited text file if the

  • 0

I’m having difficulty combining some lines in a comma delimited text file if the first field is the same. This is my file:

Area 1 Chiller Grids aB aN and a1 a6,test,1,Ground Floor Framing
Area 1 Chiller Grids aB aN and a1 a6,test,2,Monorails West
Area 1 Chiller Grids aB aN and a1 a6,test,6,Roof Framing West
Area 1 Chiller Grids aB aN and a1 a6,test,11,Bullnose West
Area 2 Office Grids aN zA and a1 a6,101806,3,First Floor Framing East
Area 2 Office Grids aN zA and a1 a6,101806,5,Mezz Floor Framing
Area 2 Office Grids aN zA and a1 a6,101806,7,Roof Framing East
Area 2 Office Grids aN zA and a1 a6,101806,9,First Floor Ceiling
Area 3 Bridge Grids yA yE and a1 10x,101807,4,Link Floor Framing
Area 3 Bridge Grids yA yE and a1 10x,101807,8,Link Roof Framing
Area 3 Bridge Grids yA yE and a1 10x,101807,10,Bridge Catwalks
Area 3 Bridge Grids yA yE and a1 10x,101807,13,Stair 1

I need the output to be this:

Area 1 Chiller Grids aB aN and a1 a6,test,1-2-6-11,Ground Floor Framing-Monorails West-Roof Framing West-Bullnose West
Area 2 Office Grids aN zA and a1 a6,101806,3-5-7-9,First Floor Framing East-Mezz Floor Framing-Roof Framing East-First Floor Ceiling
Area 3 Bridge Grids yA yE and a1 10x,101807,4-8-10-13,Link Floor Framing-Link Roof Framing-Bridge Catwalks-Stair 1

How can I go about this?
I’ve tried some linq code I found on here but it doesn’t quite get what I want and I’m not sure how to make it do it:

                var a = System.IO.File.ReadAllLines(@"X:\Steelcad_Project_Files\" + dir + "\\manager1.txt");
                var b = System.IO.File.ReadAllLines(@"X:\Steelcad_Project_Files\" + dir + "\\manager.txt");

                var query =
                    from bline in b
                    let parts = bline.Split(',')
                    group parts[2] by parts[0] into bg
                    join aline in a on bg.Key equals aline
                    select aline + "," + string.Join("-", bg.ToArray());

                System.IO.File.WriteAllLines(@"X:\Steelcad_Project_Files\" + dir + "\\result.txt", query.ToArray());

Where the manager1 file only has the first field in it, like so:

Area 1 Chiller Grids aB aN and a1 a6
Area 2 Office Grids aN zA and a1 a6
Area 3 Bridge Grids yA yE and a1 10x

I would like, if possible, to only use 1 file though.
Any help would be much appreciated. Thanks

EDIT: Is it possible to sort the lines based on line 0 and then line 2? If it was 1-11-15-2-6 can it be rearranged to 1-2-6-11-15 but keeping all the Area 1’s together etc?

  • 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-20T15:10:05+00:00Added an answer on May 20, 2026 at 3:10 pm
    var output = File.ReadAllLines(@"D:\\manager.txt")
        .Select(line => line.Split(','))
        .GroupBy(line => line[0] + "," + line[1])
        .Select(group =>
             group.Key + "," + 
             String.Join("-", group.Select(line => line[2]).ToArray()) + "," +
             String.Join("-", group.Select(line => line[3]).ToArray())
        );
    
    • 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 just tried to save a simple *.rtf file with some websites and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have some data like this: 1 2 3 4 5 9 2 6
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm making a simple page using Google Maps API 3. My first. One marker

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.