I'm trying to create a timetables.txt from other files, and I have this so far.
static void Main(string[] args)
{
string Routes = @"C:\Users\peepee poopoo\gtfs\routes.txt";
var column1 = new List<string>();
var column2 = new List<string>();
using (var rd = new StreamReader(Routes))
{
while (!rd.EndOfStream)
{
var splits = rd.ReadLine().Split(',');
column1.Add(splits[0]);
column2.Add(splits[1]);
}
}
// print column1
Console.WriteLine("Column 1:");
foreach (var element in column1)
Console.WriteLine(element);
// print column2
Console.WriteLine("Column 2:");
foreach (var element in column2)
Console.WriteLine(element);
}
However, I need the first column of every row in the list to have a number that just counts up from 1. How can I do this?
Just see the code written below and add it.
var dictionary = new Dictionart<string, string>();
using (var rd = new StreamReader(Routes))
{
while (!rd.EndOfStream)
{
var splits = rd.ReadLine().Split(',');
dictionary.Add(splits[0], splits[1]);
}
}
foreach(var item in dictionary)
{
Console.WriteLine(item.Key + "\t" + item.Value);
}