static void Main(string[] args) { //string csv_file_path = string.Empty; //string csv_file_path = @"C:\ASA\input\demodata.csv"; //string[] filePath = Directory.GetFiles(@"C:\Users\Anindita\OneDrive\Hadoop Resources\Training\TwitterDemo\TwitterData\", "*.csv"); //int size = filePath.Length; //for (int i = 0; i < size; i++) //{ // Console.WriteLine(filePath[i]); // csv_file_path = filePath[i]; //} string csv_file_path = @"C:\Users\Anindita\OneDrive\Hadoop Resources\Training\TwitterDemo\TwitterData\TweetsGeo.csv"; DataTable csvData = GetDataTableFromCSVFile(csv_file_path); Console.WriteLine("Rows count:" + csvData.Rows.Count); DataTable table = csvData; foreach (DataRow row in table.Rows) { // Console.WriteLine("---Row---"); foreach (var item in row.ItemArray) { data = item.ToString(); Console.Write(data); var eventHubClient = EventHubClient.CreateFromConnectionString(connectionString, eventHubName); //while (true) //{ try { Regex reg = new Regex("^[A-Za-z0-9]+$"); foreach (DataRow rows in table.Rows) { var info = new Tweets { DateTime = rows.ItemArray[0].ToString(), TwitterUserName = rows.ItemArray[1].ToString(), ProfileLocation = rows.ItemArray[2].ToString(), MorePreciseLocation = rows.ItemArray[3].ToString(), Country = rows.ItemArray[4].ToString(), TweetID = rows.ItemArray[5].ToString() }; if(reg.IsMatch(info.MorePreciseLocation)) { info.MorePreciseLocation = ""; info.Country = ""; info.TweetID = rows.ItemArray[3].ToString(); } if(info.ProfileLocation == "") { info.ProfileLocation = ""; info.TweetID = rows.ItemArray[3].ToString(); } var serializedString = JsonConvert.SerializeObject(info); var message = data; Console.WriteLine("{0}> Sending events: {1}", DateTime.Now.ToString(), serializedString.ToString()); eventHubClient.SendAsync(new EventData(Encoding.UTF8.GetBytes(serializedString.ToString()))); } } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("{0} > Exception: {1}", DateTime.Now.ToString(), ex.Message); Console.ResetColor(); } Task.Delay(200); //} } } // Console.ReadLine(); Console.WriteLine("Press Ctrl-C to stop the sender process"); Console.WriteLine("Press Enter to start now"); Console.ReadLine(); // SendingRandomMessages().Wait(); }