Created
December 14, 2017 11:32
-
-
Save s0ren/53d34c5ca90fa4bb891494c4dc47a8e7 to your computer and use it in GitHub Desktop.
Udskrivning til, indlæasning fra komma separerede filer (csv: comma separated values)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
String[] post = { "25780181", "Karsten Magnusson", "Smedebakken 3", "4330", "Kr. Hvalsø" }; | |
String linie = String.Join(",", post); | |
//Regex.Matches(linie, "([^,]),{4}([^,])"); | |
File.AppendAllText("/d46/db.txt", linie+"\n", Encoding.Unicode); | |
Console.WriteLine("Har skrevet {0} til db.txt", linie); | |
// Læser | |
String[] poster = File.ReadAllLines("/d46/db.txt", Encoding.Unicode); | |
// vis linier | |
foreach (string linien in poster) | |
{ | |
Console.WriteLine(linien); | |
} | |
foreach (string l in poster) | |
{ | |
string[] felter = l.Split(','); | |
foreach(string f in felter) | |
{ | |
Console.WriteLine(f); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment