Last active
June 13, 2017 01:54
-
-
Save TsuyoshiUshio/56267fd1428760057bfadb118abc7a1e to your computer and use it in GitHub Desktop.
Visual Studio Hack
This file contains 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
using CsvHelper; | |
using MongoDB.Bson; | |
using MongoDB.Driver; | |
using System; | |
using System.IO; | |
using System.Text; | |
using System.Threading; | |
namespace CSVTest | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Console.Write(System.IO.Directory.GetCurrentDirectory()); | |
using (FileStream fs = new FileStream(args[0], FileMode.Open)) | |
{ | |
using (StreamReader sr = new StreamReader(fs)) | |
{ | |
var csv = new CsvReader(sr); | |
while(csv.Read()) | |
{ | |
var id = csv.GetField<int>(0); | |
var name = csv.GetField<string>(1); | |
Console.WriteLine("\nid: {0}, name: {1}", id, name); | |
} | |
} | |
} | |
var client = new MongoClient("mongodb://removethis:JyFUWGu78lEVANZuucNK7H9HNd85dJAeXw67AkWSHoDVjtQBVYP9NVJUEIw19WPvRnDrSkfk2yxs0JmDrA1YOQ==@removethis.documents.azure.com:10255/?ssl=true&replicaSet=globaldb"); | |
var db = client.GetDatabase("sampledb"); | |
var collection = db.GetCollection<BsonDocument>("sample"); | |
var document = collection.Find(new BsonDocument()).FirstOrDefault(); | |
Console.WriteLine(document.ToString()); | |
Console.WriteLine("Hello World!"); | |
Thread.Sleep(20000); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment