Any help would be great please! I'm importing Google contacts by CSV. The problem is I can get the value of only specific header of the CSV file as I mentioned in the code. Can anyone get me the source code to get the entire set while importing the Google CSV file?
private void GoogleCsv()
{
StreamReader Sr = new StreamReader(Server.MapPath("CSVLoad//" + FileUpload.FileName));
System.Text.StringBuilder sb = new System.Text.StringBuilder();
string s;
Int64 count = 0, flag = 0;
while (!Sr.EndOfStream)
{
s = Sr.ReadLine();
a = s.Split(',')[0];
b = s.Split(',')[1];
c = s.Split(',')[2];
d = s.Split(',')[3];
e = s.Split(',')[4];
if (count == 0)
{
if ((a == "Name") && (b == "E-mail 1 - Value") && (c == "Phone 1 - Value") && (d == "Address 1 - Formatted") && (e == "Organization 1 - Name"))
{
flag = flag + 1;
count = count + 1;
}
else
{
break;
}
}
else if (count > 0)
{
if (flag == 1)
{
Contact contact = new Contact();
contact.ContactFirstName = a;
contact.ContactLastName = "";
contact.ContactEmail = b;
contact.CompanyName = e;
contact.ContactPhone = "";
contact.MobileNo = c;
contact.Designation = d;
contact.Streetone = "";
contact.Streettwo = "";
contact.Area = "";
contact.Userid = Convert.ToInt64(Session["UserId"].ToString());
contact.Organizationid = Convert.ToInt64(Session["OrgId"].ToString());
contact.Stateid = 19;
contact.Countryid = 2;
contact.Createdby = 106;
contact.Industryid = 287;
contact.Accgroupid = 627;
_importController.CsvImportDetails(contact);
}
}
}
Sr.Close();
File.Delete(Server.MapPath("CSVLoad//" + FileUpload.FileName));
}