private Registrant ParseRegistrant(IEdgarDatasetsRepository repository, string cik, List <string> fieldNames, List <string> fields)
        {
            Registrant r = repository.GetRegistrant(cik);

            if (r == null)
            {
                r      = new Registrant();
                r.CIK  = int.Parse(cik);
                r.Name = fields[fieldNames.IndexOf("name")];
                string value = fields[fieldNames.IndexOf("sic")];
                r.SIC        = string.IsNullOrEmpty(value) ? null : repository.GetSIC(value);
                value        = fields[fieldNames.IndexOf("countryba")];
                r.CountryBA  = String.IsNullOrEmpty(value) ? null : value;
                value        = fields[fieldNames.IndexOf("cityba")];
                r.CityBA     = String.IsNullOrEmpty(value) ? null : value;
                value        = fields[fieldNames.IndexOf("countryinc")];
                r.CountryInc = String.IsNullOrEmpty(value) ? null : value;
                value        = fields[fieldNames.IndexOf("ein")];
                r.EmployeeIdentificationNumber = string.IsNullOrEmpty(value) ? (int?)null : int.Parse(value);
                r.FilerStatus             = fields[fieldNames.IndexOf("afs")];
                r.WellKnownSeasonedIssuer = fields[fieldNames.IndexOf("wksi")] == "1";
                value = fields[fieldNames.IndexOf("fye")];
                if (string.IsNullOrEmpty(value))
                {
                    r.FiscalYearEndDate = null;
                }
                else
                {
                    r.FiscalYearEndDate = Convert.ToInt16(value);
                }
                repository.Add(r);
            }
            return(r);
        }