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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:41:40+00:00 2026-05-26T14:41:40+00:00

The below is a CSV string I am working with. Its much bigger in

  • 0

The below is a CSV string I am working with. Its much bigger in reality but this is enough to display a pattern.

Please note that I have put this CSV on seperate lines just to demonstrate my pattern easily.

After a CSV split the number of fields are variable depending on how big the original string is i.e. the string is a variable length which makes the number of indexes variable

The letter in the pattern may not always be P, it could be U, O or F

G9999999990001800002777107050,
G9999999990002777107HMNLAQKPRLLHRAQRWJ010,
1,
3,
29,
P,
6.74,
11.23,
07,
U,
5.25,
14.29,
08,
O,
6.89,
16.92,
07,
P,
5,
4,

I want to pick up the 5th (29) and 6th (P) elements and then miss 2 elements and then pick the next element (07) and the one after (P) and so on until I get to the end of the string.

In this example I will have
29
P
07
P
08
P
07
P

Is there an easy way to do this, I assume LINQ will offer something

Thanks

  • 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-26T14:41:41+00:00Added an answer on May 26, 2026 at 2:41 pm

    A full demo on http://ideone.com/EDof0

    using System;
    using System.Linq;
    using System.Collections.Generic;
    
    public class Program
    {
        public static IEnumerable<int> SpecialIndexes()
        {
            int i=4; 
    
            while (i<Int32.MaxValue)
            {
                yield return i++;
                yield return i++;
                i += 2;
            }
        }
    
        public static void Main(string[] args)
        {
            var csvString = "G9999999990001800002777107050,G9999999990002777107HMNLAQKPRLLHRAQRWJ010,1,3,29,P,6.74,11.23,07,P,5.25,14.29,08,P,6.89,16.92,07,P,5,4,";
    
            var fields = csvString.Split(',');
            var selected = SpecialIndexes()
                .TakeWhile(i => i<fields.Length)
                .Select(i => fields[i]);
    
            Console.WriteLine(string.Join(" ", selected.ToArray()));
        }
    }
    

    Output:

    29 P 07 P 08 P 07 P
    

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

Sidebar

Related Questions

I have a large number of csv files that look like this below: xxxxxxxx
I have a CSV in this below format 11000,Christopher,Nolan,MR.,Inception,25993,France,Lefoullon,Paris,920,Director,*461-7755,33-461-7755,12175,O'Horner, James,12300,Glebova, Nathalie,,Christophe.Nolan@movies.com,Capital,NEW Regarding Java Split
I am trying to create a CSV file using the C# code below: string
This is a strange one, I have everything working but in the controller code
How to transpose CSV string in rows? In the example below, rows are transposed
I am using the below code to Export DataTable to MS Word,Excel,CSV format &
I want to trim the column headers of a CSV file, fields below is
Below is my current char* to hex string function. I wrote it as an
I have a CSV file which the code below uses to put the contents
The PHP's crc32 support string as input.And For a file , below code will

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.