21-11-23 03:18 PM
Hi Everyone,
I have a requirement where I need to push/load CSV data file into Elastic Search,
Im Getting error in code stage as : Missing compiler required member Microsoft.Csharp.RuntimeBinder.CsharpArguementInfo.Create.
But I have Added all dll's required.
If anyone have idea on this, Kindly help in this, in the below I have attached the code.
These are the used namespace:
CsvHelper;
ElasticSearch;
Elastic.Clients.Elasticsearch;
System;
System.Collections.Generic;
System.IO;
System.Linq;
System.Text;
System.Threading.Tasks;
Elastic.Transport;
System.Net.Mime.MediaTypeNames;
This is the C# Code:
try
{
// Create the Elasticsearch client.
var settings = new ElasticsearchClientSettings(new Uri("http://172.25.105.36:9200"))
.Authentication(new BasicAuthentication("elastic", "Infy@123"))
.DefaultIndex("qualys-test-2");
// Set your default index name here
var client = new ElasticsearchClient(settings);
// Open the CSV file.DefaultIndex().'
using (var reader = new StreamReader(@"C:\Users\SoumyaBalayyakalal\Downloads\Qualys NC_20230901 (1).csv"))
using (var csv = new CsvReader(reader, new CsvHelper.Configuration.CsvConfiguration(System.Globalization.CultureInfo.InvariantCulture)))
{
var records = csv.GetRecords<dynamic>();
// Iterate over the CSV records and push them to Elasticsearch.
foreach (var record in records)
{
var jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(record);
var indexResponse = client.Index(jsonString);
//var indexResponse = client.Index(record);
//var indexResponse = await client.IndexAsync(record, "qualys-test-2");
//var indexResponse = Task.Run(() => client.Index(record, "qualys-test-2")).Result;
if (!indexResponse.IsValid)
{
Console.WriteLine(indexResponse);
}
}
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
Thanks,------------------------------
Soumya k RPA Developer
RPA Developer
Qualesce India Private Limited
Bangalore
------------------------------
26-11-23 08:05 PM
Hello.
Check if the dll corresponds to the x86 or x64 operating system platform, I already had a similar problem and in this case this was it.
Regards,