I'm reading and writing some csv files that are stored in Azure Blob Storage.
The files have headers and I would like to add 2 additional columns with defined headers and values to the files and write them to another location. I'm using StreamReader and StreamWriter to read and write to the files, but was having difficulty in appending like I normally would do with the File.ReadLines method.
The new columns and associated values are what I would like written to a new blob, depicted below.
|Column A|Column B|Column C | New Column 1 | New Column 2 | |--------|--------|---------|--------------|--------------| | 1 | 2 | 3 | new value | new value | | 4 | 5 | 6 | new value | new value |
*EDIT -- Added Code below that highlights what functionality I would like, but I'm restricted due to working with streams
var csv = File.ReadLines(rawfilePath).Select((line, index) => index == 0 ? line + ",Order" : line + "," + index.ToString()) .ToList(); File.WriteAllLines(processedfilePath, csv);