I have a string that looks like this
start
"contrib_11_FICO_Score = 0.7474262402579245 contrib_27_OtherPayments = -0.11397237107501418 contrib_20_LTV = 0.4209136780360599 contrib_0_AcctsOnUs = -0.195553721371136 contrib_19_InstallmentPayments = 0.08134999563389797 contrib_1_Amount = 0.07752028501333455 contrib_10_EstDebtToIncome = 0.19793275869285348 contrib_45_CVTE_ProductShortName.0 = 0.08545325753810393 contrib_21_LoanTerm = -0.20186524569828262 contrib_43_SatisfactoryLast2Yrs = 0.0710695727171011 contrib_50_WoE_ProductShortName.0 = -0.022073850549082376 contrib_31_PLCollectionTotal = 0.12617956675796796 contrib_40_RevBalToHighCredit = -0.5009070556076041 contrib_42_RevolvingPayments = 0.14787007118011708 contrib_39_RepoTotal = 0.002261663457841503 contrib_30_PLCollectionLast2yrs = 0.047241412208721086 contrib_15_InquiriesOnUs = -0.08118475273646548 contrib_17_InquiriesTotal = -0.23934745152247694 contrib_16_InquiriesToday = 0.06067597032236759 contrib_23_OilTE = -0.009115867521724635 contrib_14_InquiriesLast6mos = -0.01669536361883669 contrib_8_DTI = 0.40070958319864824 contrib_44_SatisfactoryTotal = -0.29471031930209096 contrib_22_Mortgage = -0.13973120155639737 contrib_3_AvgRevolvingBalance = -0.1339820646758586 contrib_41_RevolvingCount = 0.008316986809544236 contrib_32_Plus30Last2Yrs = 0.0315266336181764 contrib_29_OtherPublicTotal = 0.0025079738312499887 contrib_12_Inquiries30days = 0.08842218013671509 contrib_36_Plus90Last2Yrs = 0.03415210455083352 contrib_6_BankruptcyLast2yrs = 0.0037646391378712307 contrib_34_Plus60Last2Yrs = 0.014917255339436795 contrib_28_OtherPublicLast2yrs = 9.508765288605479E-4 contrib_bias = 0.7414680413223248"
and I'm trying to coerce it to a hash, like this.
end
{"contrib_11_FICO_Score"=>0.7474262402579245, "contrib_27_OtherPayments"=>-0.11397237107501418, "contrib_20_LTV"=>0.4209136780360599, "contrib_0_AcctsOnUs"=>-0.195553721371136, "contrib_19_InstallmentPayments"=>0.08134999563389797, "contrib_1_Amount"=>0.07752028501333455, "contrib_10_EstDebtToIncome"=>0.19793275869285348, "contrib_45_CVTE_ProductShortName"=>0.08545325753810393, "contrib_21_LoanTerm"=>-0.20186524569828262, "contrib_43_SatisfactoryLast2Yrs"=>0.0710695727171011, "contrib_50_WoE_ProductShortName"=>-0.022073850549082376, "contrib_31_PLCollectionTotal"=>0.12617956675796796, "contrib_40_RevBalToHighCredit"=>-0.5009070556076041, "contrib_42_RevolvingPayments"=>0.14787007118011708, "contrib_39_RepoTotal"=>0.002261663457841503, "contrib_30_PLCollectionLast2yrs"=>0.047241412208721086, "contrib_15_InquiriesOnUs"=>-0.08118475273646548, "contrib_17_InquiriesTotal"=>-0.23934745152247694, "contrib_16_InquiriesToday"=>0.06067597032236759, "contrib_23_OilTE"=>-0.009115867521724635, "contrib_14_InquiriesLast6mos"=>-0.01669536361883669, "contrib_8_DTI"=>0.40070958319864824, "contrib_44_SatisfactoryTotal"=>-0.29471031930209096, "contrib_22_Mortgage"=>-0.13973120155639737, "contrib_3_AvgRevolvingBalance"=>-0.1339820646758586, "contrib_41_RevolvingCount"=>0.008316986809544236, "contrib_32_Plus30Last2Yrs"=>0.0315266336181764, "contrib_29_OtherPublicTotal"=>0.0025079738312499887, "contrib_12_Inquiries30days"=>0.08842218013671509, "contrib_36_Plus90Last2Yrs"=>0.03415210455083352, "contrib_6_BankruptcyLast2yrs"=>0.0037646391378712307, "contrib_34_Plus60Last2Yrs"=>0.014917255339436795, "contrib_28_OtherPublicLast2yrs"=>9.508765288605479E-4, "contrib_bias"=>0.7414680413223248}
I can use gsub(" = ","=>")
.gsub(" contrib",","contrib").gsub("\","")
but I end up with
\"contrib
The backslashes prevent me from converting this to a hash. How can I strip the backslashes out? I would have thought that the escape character would work, but apparently not.
I also tried splitting the string on the space, but this gave me an array of strings and not a hash.
Thanks for any suggestions!
Related
i would like to visualize what i will get after concatenation of map and struct in matlab , for instance let us consider following Map Container
ticketMap = containers.Map(...
{'2R175', 'B7398', 'A479GY', 'NZ1452'}, ...
{'James Enright', 'Carl Haynes', 'Sarah Latham', ...
'Bradley Reid'});
key/value structure of this map is clear for me, now let us suppose we have following structure
s1.ticketNum = '2S185'; s1.destination = 'Barbados';
s1.reserved = '06-May-2008'; s1.origin = 'La Guardia';
s2.ticketNum = '947F4'; s2.destination = 'St. John';
s2.reserved = '14-Apr-2008'; s2.origin = 'Oakland';
s3.ticketNum = 'A479GY'; s3.destination = 'St. Lucia';
s3.reserved = '28-Mar-2008'; s3.origin = 'JFK';
s4.ticketNum = 'B7398'; s4.destination = 'Granada';
s4.reserved = '30-Apr-2008'; s4.origin = 'JFK';
s5.ticketNum = 'NZ1452'; s5.destination = 'Aruba';
s5.reserved = '01-May-2008'; s5.origin = 'Denver';
we have 5 structure with different fields, now following commands
seatingMap = containers.Map( ...
{'23F', '15C', '15B', '09C', '12D'}, ...
{s5, s1, s3, s4, s2});
make sense for me because for instance using key 23F i can access fields of s1 structure, for instance
>> seatingMap('23F').origin
ans =
'Denver'
all those parts are clear for me, now Using ticketMap and seatingMap together, you can find the name of the person who has reserved seat 15B
ticket = seatingMap('15B').ticketNum;
passenger = ticketMap(ticket)
but is that optimal way?thanks in advance
I got a strange problem, Codeigniter Pagination highlights last link when current link is first
$route['favorite/(:num)'] = 'user/favorite/$1';
$route['favorite/(:num)/page/(:num)'] = 'user/favorite/$1/$2';
$this->load->library('pagination');
$config['base_url'] = "/favorite/$user_fav_id/page";
$config['total_rows'] = $this->user_model->count_user_fav_all_movies($user_id, $user_fav_id);
$config['per_page'] = 3;
$config['use_page_numbers'] = true;
$config['first_link'] = 'в начало';
$config['last_link'] = 'в конец';
$config['next_link'] = '';
$config['prev_link'] = '';
$config['first_url'] = "/favorite/$user_fav_id";
$this->pagination->initialize($config);
You have to tell CI at what page you are currently at, by providing uri_segment :
$config['uri_segment'] = $this->uri->total_segments();
Or
$config['uri_segment'] = 4;
$this->db->select('SUM(status = In Stock)As In Stock,SUM(status = Allocated)AS Allocated,SUM(status = Decommission) as Decommission,SUM(status = In transit)AS In Transit');
// $this->db->from('assets');
$this->db->group_by("assettype,location");
$query = $this->db->get('assets');
Getting syntax error in the above query.
Kindly help
change
$this->db->select('SUM(status = "In Stock")As In_Stock,SUM(status = "Allocated")AS Allocated,SUM(status = "Decommission") as Decommission,SUM(status = "In transit")AS In_Transit');
How do I create a tax rate in QBO using API v3 and the TaxService resource? When I try to add it the same way as I would any other object, Visual Studio gives me this error: "The type 'Intuit.Ipp.Data.TaxService' cannot be used as type parameter 'T' in the generic type or method Intuit.Ipp.DataService.DataService.Add(T)'. There is no implicit reference conversion from 'Intuit.Ipp.Data.TaxService' to 'Intuit.Ipp.Data.IEntity'."
Here's the code:
Intuit.Ipp.Data.TaxService ts = new Intuit.Ipp.Data.TaxService();
// Populate fields here...
DataService ds = new DataService(ServiceContext);
Intuit.Ipp.Data.TaxService newTs = ds.Add<Intuit.Ipp.Data.TaxService>(ts);
Use GlobalTaxService endpoint and JSON format only. Try this code:
GlobalTaxService taxSvc = new GlobalTaxService(context);
Intuit.Ipp.Data.TaxService taxCodetobeAdded = new Data.TaxService();
taxCodetobeAdded.TaxCode = "taxC_" + Guid.NewGuid().ToString("N");
QueryService<TaxAgency> taxagency = new QueryService<TaxAgency>(context);
TaxAgency taxagencyResult = taxagency.ExecuteIdsQuery("select * from TaxAgency").FirstOrDefault<TaxAgency>();
List<TaxRateDetails> lstTaxRate = new List<TaxRateDetails>();
TaxRateDetails taxdetail1 = new TaxRateDetails();
taxdetail1.TaxRateName = "taxR1_" + Guid.NewGuid().ToString("N");
taxdetail1.RateValue = 3m;
taxdetail1.RateValueSpecified = true;
taxdetail1.TaxAgencyId = taxagencyResult.Id.ToString();
taxdetail1.TaxApplicableOn = TaxRateApplicableOnEnum.Sales;
taxdetail1.TaxApplicableOnSpecified = true;
lstTaxRate.Add(taxdetail1);
TaxRateDetails taxdetail2 = new TaxRateDetails();
taxdetail2.TaxRateName = "taxR2_" + Guid.NewGuid().ToString("N");
taxdetail2.RateValue = 2m;
taxdetail2.RateValueSpecified = true;
taxdetail2.TaxAgencyId = taxagencyResult.Id.ToString();
taxdetail2.TaxApplicableOn = TaxRateApplicableOnEnum.Sales;
taxdetail2.TaxApplicableOnSpecified = true;
lstTaxRate.Add(taxdetail2);
//TaxRateDetails taxdetail3 = new TaxRateDetails();
//taxdetail3.TaxRateName = "rate298";
//taxdetail3.TaxRateId = "2";
//lstTaxRate.Add(taxdetail3);
taxCodetobeAdded.TaxRateDetails = lstTaxRate.ToArray();
Intuit.Ipp.Data.TaxService taxCodeAdded = taxSvc.AddTaxCode(taxCodetobeAdded);
How can I optimize all of these routes into one. As we do in .htaccess file.
routes.addemails.type = "Zend_Controller_Router_Route_Regex"
routes.addemails.route = "campaign/email/add"
routes.addemails.defaults.module = campaignManagement
routes.addemails.defaults.controller = Email
routes.addemails.defaults.action = add
routes.updateEmail.type = "Zend_Controller_Router_Route_Regex"
routes.updateEmail.route = "campaign/email/edit/?([a-zA-Z0-9_-]+)?"
routes.updateEmail.defaults.module = campaignManagement
routes.updateEmail.defaults.controller = Email
routes.updateEmail.defaults.action = edit
routes.updateEmail.map.key = 1
routes.delEmail.type = "Zend_Controller_Router_Route_Regex"
routes.delEmail.route = "campaign/email/delete/?([a-zA-Z0-9_-]+)?"
routes.delEmail.defaults.module = campaignManagement
routes.delEmail.defaults.controller = Email
routes.delEmail.defaults.action = delete
routes.delEmail.map.id = 1
I've not set up a route using a config file, but at a glance try:
routes.emails.route = "campaign/email/(add|edit|delete)/?([a-zA-Z0-9_-]+)?"
routes.emails.map.action = 1
routes.emails.map.id = 2
I am assuming that the map.* are the variables in the url (so action is the first bit of regex, with id being the second bit of regex. Correct me if I'm wrong).