-
Notifications
You must be signed in to change notification settings - Fork 90
Read Entire CSV File, .NET style
NN--- edited this page Apr 18, 2012
·
5 revisions
- Category: Input/Output
- Description: Read an entire text file as a string using .NET I/O utilities and abstractions.
- Code:
using System;
using System.Console;
using System.IO.File;
using Nemerle;
using Nemerle.Collections;
// Write a test file
WriteAllLines("test.csv", array["Desmond, Barrow, Market Place, 2", "Molly, Singer, Band, 12" ]);
// Now read it
def text = ReadAllLines("test.csv");
def linesSplitIntoWords = text.Map(x => x.Split(array[','], StringSplitOptions.RemoveEmptyEntries));
foreach (l in linesSplitIntoWords)
WriteLine($<#..$(l; ", "; w => $"$w")#>);
- Execution Result:
Desmond, Barrow, Market Place, 2
Molly, Singer, Band, 12
[Copyright ©](Terms of use, legal notice)