static void Main(string[] args) { string folderPath = args[0]; Creds creds = new Creds { host = "84dc23c9-0d9c-4e8b-a186-079196664732-bluemix.cloudant.com", password = "******", username = "******" }; CloudantBulkUploader uploader = new CloudantBulkUploader(creds); IEnumerable <string> files = Directory.GetFiles(folderPath, "*.csv").OrderBy(s => s); Console.WriteLine("Starting file processing..."); foreach (string file in files) { List <ForexEntry> entries = new List <ForexEntry>(); Console.WriteLine($"Processing file {file}..."); using (StreamReader reader = new StreamReader(file)) { string line; while ((line = reader.ReadLine()) != null) { string[] parts = line.Split(','); DateTime timestamp = DateTime.ParseExact(parts[0], "yyyyMMdd HHmmssfff", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal); entries.Add(new ForexEntry(timestamp.Ticks, float.Parse(parts[1]), float.Parse(parts[2]))); } } Console.WriteLine("Finished proceessing..."); Console.WriteLine("Uploading results to Cloudant..."); uploader.Upload(entries); } }
/// <summary> /// Initializes a new instance of the <see cref="CloudantBulkUploader"/> class. /// </summary> /// <param name="cloudantCreds">The cloudant creds.</param> public CloudantBulkUploader(Creds cloudantCreds) { this.cloudantCreds = cloudantCreds; }