deucalion0
deucalion0

Reputation: 2440

How can I add consecutive numbers to the front of my lines of text using C# and/or Notepad++?

I basically have a whole list of data that looks like this:

text', 0, 16, 0, 160),
text text', 0, 36, 0, 720),
text text text', 6, 14, 200, 400),
text text', 6, 20, 40, 185),
text text text text', 6, 6, 80, 80),
text text', 0, 18, 0, 260),
text text text', 3, 3, 60, 60),

I need this to look like this:

(1444, text text', 0, 36, 0, 720),
(1445, text text text', 6, 14, 200, 400),
(1446, text text', 6, 20, 40, 185),
(1447, text text text text', 6, 6, 80, 80),
(1448, text text', 0, 18, 0, 260),
(1449, text text text', 3, 3, 60, 60),

So I basically wrote a for loop in C# to generate the numbers:

 for(int i =0; i < amount; i ++)
        {
            Console.WriteLine("("+counter+",");
            counter++;
        }

Counter being the numbers I need and amount being the amount of times I need numbers generated.

I am trying to figure out how to get "(1111," in front of "text', 0, 0, 0, 0)," per each line, I was trying to find and replace in notepad but I couldn't get it to work, is there a way I could do the whole thing in C#? Or any other way at all?

Upvotes: 0

Views: 307

Answers (3)

mletterle
mletterle

Reputation: 3968

Yes, use the following resource: http://msdn.microsoft.com/en-us/library/ezwyzy7b.aspx

And try doing something like:

Console.Writeline("(" + counter + "," + line);

Upvotes: 2

Austin Salonen
Austin Salonen

Reputation: 50235

var indexedLines = yourData.Select((line, idx) => new {Line = line, Index = idx});

foreach(var indexedLine in indexedLines)
    Console.WriteLine("({0}, {1}", indexedLine.Index, indexedLine.Line);

Upvotes: 5

Jakub Konecki
Jakub Konecki

Reputation: 46008

Can't you just use Excel or other spreadsheet processor?

Upvotes: 4

Related Questions