Search Results

Search found 17734 results on 710 pages for 'values'.

Page 2/710 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Passing Values from a View to itself with parameters getting null values ?

    - by vsj
    Hi all, I am trying to get values from a view which i have the code below and I am taking the start date value from the view input text box and posting it back but I am still getting null except for the apikey and userkey.Here are the two views.. public ActionResult View1(string apiKey, string userId) { StartGoalViewModel vm = new StartGoalViewModel(); vm.ApiKey = apiKey; vm.UserId = userId; vm.GoalTypeId =1; vm.StartDate = null; return View(vm); } VIEW1.ASPX <% Html.BeginForm(); %> <%= Html.TextBox("name", Model.StartDate) %> <input type="submit" value="Start" /> <% Html.EndForm(); %> [HttpPost] public ActionResult VIEW1 (StartGoalViewModel fm) { // I get StartDate null... }

    Read the article

  • jQuery: form input values turns up undefined

    - by Seerumi
    Having problem with this bit of code qith jQuery. it should pick the values from current form and then submit them, but when I try to get them with jQuery they always turn up undefined. I know the SQL results are fine since they show correctly in HTML table, so it must be my inferior javascript skills. New with jQuery and I'm at loss :( PHP/HTML: echo "<table>\n" while ($row = odbc_fetch_array($query)) { echo "<form class='catForm'>\n"; echo "<input type=hidden class='catID' name='catID' value='".$row['running_id']."'/>\n"; echo "<tr>\n"; echo "<td>".$row['running_id']."</td>\n"; echo "<td>".$row['site_id']."</td>\n"; echo "<td>".$row['main_category']."</td>\n"; echo "<td>".$row['map_name']."</td>\n"; echo "<td><input type=textfield class='bCatID' value='".$row['mapping_id']."' size=6/></td>\n"; echo "<td><input type=submit class='saveCat' value='Save'/></td>\n"; echo "<td><input type=submit class='killCat' value='Delete' /></td>\n"; echo "</tr>\n"; echo "</form>\n"; } echo "</table>"; jQuery: $(".catForm").submit(function () { var id = $(this).find('.catID').val(); var bCatID = $(this).find('.bCatID').val(); var dataString = 'id='+id+'&bCatID='+bCatID; $.ajax({ type: "POST", url: 'adminUI/bin/updateSCategories.php', dataType : 'json', data: dataString, success: function(data) { if (data.error == true) $('.failure').html("Error, save failed.").show().fadeOut(2000); if (data.error == false) $('.success').html("Saved succesfully").show().fadeOut(2000); }, error: function(XMLHttpRequest, textStatus, errorThrown) { $('.failure').html("Error, save failed.").show().fadeOut(2000); } }); return false; }); RESULT: id: undefined bCatID: undefined

    Read the article

  • how to get unique values set from a repeating values list

    - by Mariselvam
    I need to parse a large log file (flat file), which contains two column of values (column-A , column-B). Values in both columns are repeating. I need to find for each unique value in column-A , I need to find a set of column-B values. Is this can be done using unix shell command or need to write any perl or python script? What are the ways this can be done? Example: xxxA 2 xxxA 1 xxxB 2 XXXC 3 XXXA 3 xxxD 4 output: xxxA - 2,1,3 xxxB - 2 xxxC - 3 xxxD - 4

    Read the article

  • XStream parse attributes and values at the same time

    - by gurbieta
    Hi, I have the following XML <search ver="3.0"> <loc id="ARBA0009" type="1">Buenos Aires, Argentina</loc> <loc id="BRXX1283" type="1">Buenos Aires, Brazil</loc> <loc id="ARDF0127" type="1">Aeroparque Buenos Aires, Argentina</loc> <loc id="MXJO0669" type="1">Concepcion De Buenos Aires, Mexico</loc> <loc id="MXPA1785" type="1">San Nicolas De Buenos Aires, Mexico</loc> <loc id="ARBA0005" type="1">Balcarce, Argentina</loc> <loc id="ARBA0008" type="1">Bragado, Argentina</loc> <loc id="ARBA0010" type="1">Campana, Argentina</loc> <loc id="ARBA0016" type="1">Chascomus, Argentina</loc> <loc id="ARBA0019" type="1">Chivilcoy, Argentina</loc> </search> And a City class public class City { private String id; private Integer type; private String name; // getters & setters... } I tried the following aliases to parse the XML xStream.alias("search", List.class); xStream.alias("loc", City.class); xStream.useAttributeFor("id", String.class); xStream.useAttributeFor("type", Integer.class); But I can't figure out how to set the value of the "loc" tag, if I try to transform the City object in XML I get <search> <loc id="ARBA0001" type="1"> <name>Buenos Aires</name> </loc> </search> When I really need to get this <search> <loc id="ARBA0001" type="1">Buenos Aires</loc> </search> Then, if I try to parse the XML to a City object I get the field "name" with a null value. Anybody knows how to set te correct aliases to do this? Thanks in advance.

    Read the article

  • Ajaxrequest with Wicket but multiple possilbe model values

    - by Markus Maria Miedaner
    Hi, I'm new to wicket and stuck with the following problem: I have a table with 5 rows. Each row contains 7 cells. Each cell has a unique value. Once a cell is clicked, its unqiue value should be posted to the server. I would like to register only one ajaxfallbacklink (or similar) on the table and adjust the value of the model to the unique value of cell that has been clicked. Any ideas?

    Read the article

  • Linq query with subquery as comma-separated values

    - by Keith
    In my application, a company can have many employees and each employee may have have multiple email addresses. The database schema relates the tables like this: Company - CompanyEmployeeXref - Employee - EmployeeAddressXref - Email I am using Entity Framework and I want to create a LINQ query that returns the name of the company and a comma-separated list of it's employee's email addresses. Here is the query I am attempting: from c in Company join ex in CompanyEmployeeXref on c.Id equals ex.CompanyId join e in Employee on ex.EmployeeId equals e.Id join ax in EmployeeAddressXref on e.Id equals ax.EmployeeId join a in Address on ax.AddressId equals a.Id select new { c.Name, a.Email.Aggregate(x=x + ",") } Desired Output: "Company1", "[email protected],[email protected],[email protected]" "Company2", "[email protected],[email protected],[email protected]" ... I know this code is wrong, I think I'm missing a group by, but it illustrates the point. I'm not sure of the syntax. Is this even possible? Thanks for any help.

    Read the article

  • Need help with Values

    - by Adam C
    I want to take a value ex: <input type="hidden" name="quicksearch" value="**1**" /> from a third party website. then place that value on my website ex: <input type="hidden" name="quicksearch" value="**REPLACE WITH 1**" />

    Read the article

  • Counting unique values in a column with a shell script

    - by Lilly Tooner
    Hello. I have a tab delimited file with 5 columns and need to retrieve a count of just the number of unique lines from column 2. I would normally do this with Perl/Python but I am forced to use the shell for this one. I have successfully in the past used *nix uniq function piped to wc but it looks like I am going to have to use awk in here. Any advice would be greatly appreciated. (I have asked a similar question previously about column checks using awk but this is a little different and I wanted to separate it so if someone in the future has this question this will be here) Many many thanks! Lilly

    Read the article

  • How have your coding values changed since graduating?

    - by Matt
    We all walked out of school with the stars in our eyes and little experience in "real-world" programming. How have your opinions on programming as a craft changed since you've gained more experience away from academia? I've become more and more about design a la McConnell : wide use of encapsulation, quality code that gives you warm fuzzy feelings when you read it, maintainability over execution performance, etc..., whereas many of my co-workers have followed a different path of fewer middlemen layers getting in the way, code that is right out in the open and easier to locate, even if harder to read, and performance-centric designs. What have you learned about the craft of software design which has changed the way you approach coding since leaving the academic world?

    Read the article

  • convert RGB values to equivalent HSV values using python

    - by sree01
    Hi, I want to convert RGB values to HSV using python. I got some code samples, which gave the result with the S and V values greater than 100. (example : http://code.activestate.com/recipes/576554-covert-color-space-from-hsv-to-rgb-and-rgb-to-hsv/ ) . anybody got a better code which convert RGB to HSV and vice versa thanks

    Read the article

  • accessing values in a Map container, whose values were passed on as a stream

    - by wilson88
    I am trying to get access to the object values of the objects that were sent as a stream from one class to ano ther.Aparently I can view the objects via their keys but am not so sure how to get to the values.ie Bid- values trdId,qty, price. If possible you can demostrate how I can make comparison for the prices in the containers buyers and sellers for the prices. code is as below: void Auctioneer::printTable(map bidtable) { map<int, Bid*>::const_iterator iter; cout << "\t\tBidID | TradID | Type | Qty | Price \n\n"; for(iter=bidtable.begin(); iter != bidtable.end(); iter++)//{ cout << iter->second->toString() << endl<<"\n"; //------------------------------------------------------------------------- // Creating another map for the sellers. cout<<"These are the Sellers bids\n\n"; map<int, Bid*> sellers(bidtable); sellers.erase(10);sellers.erase(11);sellers.erase(12);sellers.erase(13);sellers.erase(14); sellers.erase(15);sellers.erase(16); sellers.erase(17);sellers.erase(18);sellers.erase(19); for(iter=sellers.begin(); iter != sellers.end(); iter++) cout << iter->second->toString() << endl<<"\n"; //-------------------------------------------------------------------------- // Creating another map for the sellers. cout<<"These are the Buyers bids\n\n"; map<int, Bid*> buyers(bidtable); buyers.erase(0);buyers.erase(1);buyers.erase(2);buyers.erase(3);buyers.erase(4);buyers.erase(5); buyers.erase(6);buyers.erase(7); buyers.erase(8);buyers.erase(9); for(iter=buyers.begin(); iter != buyers.end(); iter++) //sellers.erase(10); cout << iter->second->toString() << endl<<"\n";

    Read the article

  • GSL interpolation error, values must be x values must be monotonically increasing

    - by pyCthon
    Hi my problem is that my data set is monotonically increasing but towards the end the of the data it looks like it does below ,where some of the x[i-1] = x[i] as shown below. This causes an error to be raised in GSL because it thinks that the values are not monotonically increasing. Is there a solution, fix or work around for this problem? the values are already double precision ,this particular data set starts at 9.86553e-06 and ends at .999999 would the only solution be to offset every value in a for loop? 0.999981 0.999981 0.999981 0.999982 0.999982 0.999983 0.999983 0.999983 0.999984 0.999984 0.999985 0.999985 0.999985

    Read the article

  • SQL SERVER – Storing Variable Values in Temporary Array or Temporary List

    - by pinaldave
    SQL Server does not support arrays or a dynamic length storage mechanism like list. Absolutely there are some clever workarounds and few extra-ordinary solutions but everybody can;t come up with such solution. Additionally, sometime the requirements are very simple that doing extraordinary coding is not required. Here is the simple case. Let us say here are the values: a, 10, 20, c, 30, d. Now the requirement is to store them in a array or list. It is very easy to do the same in C# or C. However, there is no quick way to do the same in SQL Server. Every single time when I get such requirement, I create a table variable and store the values in the table variables. Here is the example: For SQL Server 2012: DECLARE @ListofIDs TABLE(IDs VARCHAR(100)); INSERT INTO @ListofIDs VALUES('a'),('10'),('20'),('c'),('30'),('d'); SELECT IDs FROM @ListofIDs; GO When executed above script it will give following resultset. Above script will work in SQL Server 2012 only for SQL Server 2008 and earlier version run following code. DECLARE @ListofIDs TABLE(IDs VARCHAR(100), ID INT IDENTITY(1,1)); INSERT INTO @ListofIDs SELECT 'a' UNION ALL SELECT '10' UNION ALL SELECT '20' UNION ALL SELECT 'c' UNION ALL SELECT '30' UNION ALL SELECT 'd'; SELECT IDs FROM @ListofIDs; GO Now in this case, I have to convert numbers to varchars because I have to store mix datatypes in a single column. Additionally, this quick solution does not give any features of arrays (like inserting values in between as well accessing values using array index). Well, do you ever have to store temporary multiple values in SQL Server – if the count of values are dynamic and datatype is not specified early how will you about storing values which can be used later in the programming. Reference: Pinal Dave (http://blog.SQLAuthority.com) Filed under: PostADay, SQL, SQL Authority, SQL Query, SQL Server, SQL Tips and Tricks, T SQL, Technology

    Read the article

  • Get backreferences values and modificate these values

    - by roasted
    Could you please explain why im not able to get values of backreferences from a matched regex result and apply it some modification before effective replacement? The expected result is replacing for example string ".coord('X','Y')" by "X * Y". But if X to some value, divide this value by 2 and then use this new value in replacement. Here the code im currently testing: See /*>>1<<*/ & /*>>2<<*/ & /*>>3<<*/, this is where im stuck! I would like to be able to apply modification on backrefrences before replacement depending of backreferences values. Difference between /*>>2<<*/ & /*>>3<<*/ is just the self call anonymous function param The method /*>>2<<*/ is the expected working solution as i can understand it. But strangely, the replacement is not working correctly, replacing by alias $1 * $2 and not by value...? You can test the jsfiddle //string to test ".coord('125','255')" //array of regex pattern and replacement //just one for the example //for this example, pattern matching alphanumerics is not necessary (only decimal in coord) but keep it as it var regexes = [ //FORMAT is array of [PATTERN,REPLACEMENT] /*.coord("X","Y")*/ [/\.coord\(['"]([\w]+)['"],['"]?([\w:\.\\]+)['"]?\)/g, '$1 * $2'] ]; function testReg(inputText, $output) { //using regex for (var i = 0; i < regexes.length; i++) { /*==>**1**/ //this one works as usual but dont let me get backreferences values $output.val(inputText.replace(regexes[i][0], regexes[i][2])); /*==>**2**/ //this one should works as i understand it $output.val(inputText.replace(regexes[i][0], function(match, $1, $2, $3, $4) { $1 = checkReplace(match, $1, $2, $3, $4); //here want using $1 modified value in replacement return regexes[i][3]; })); /*==>**3**/ //this one is just a test by self call anonymous function $output.val(inputText.replace(regexes[i][0], function(match, $1, $2, $3, $4) { $1 = checkReplace(match, $1, $2, $3, $4); //here want using $1 modified value in replacement return regexes[i][4]; }())); inputText = $output.val(); } } function checkReplace(match, $1, $2, $3, $4) { console.log(match + ':::' + $1 + ':::' + $2 + ':::' + $3 + ':::' + $4); //HERE i should be able if lets say $1 > 200 divide it by 2 //then returning $1 value if($1 > 200) $1 = parseInt($1 / 2); return $1; }? Sure I'm missing something, but cannot get it! Thanks for your help, regards. EDIT WORKING METHOD: Finally get it, as mentionned by Eric: The key thing is that the function returns the literal text to substitute, not a string which is parsed for backreferences.?? JSFIDDLE So complete working code: (please note as pattern replacement will change for each matched pattern and optimisation of speed code is not an issue here, i will keep it like that) $('#btn').click(function() { testReg($('#input').val(), $('#output')); }); //array of regex pattern and replacement //just one for the example var regexes = [ //FORMAT is array of [PATTERN,REPLACEMENT] /*.coord("X","Y")*/ [/\.coord\(['"]([\w]+)['"],['"]?([\w:\.\\]+)['"]?\)/g, '$1 * $2'] ]; function testReg(inputText, $output) { //using regex for (var i = 0; i < regexes.length; i++) { $output.val(inputText.replace(regexes[i][0], function(match, $1, $2, $3, $4) { var checkedValues = checkReplace(match, $1, $2, $3, $4); $1 = checkedValues[0]; $2 = checkedValues[1]; regexes[i][1] = regexes[i][1].replace('$1', $1).replace('$2', $2); return regexes[i][1]; })); inputText = $output.val(); } } function checkReplace(match, $1, $2, $3, $4) { console.log(match + ':::' + $1 + ':::' + $2 + ':::' + $3 + ':::' + $4); if ($1 > 200) $1 = parseInt($1 / 2); if ($2 > 200) $2 = parseInt($2 / 2); return [$1,$2]; }

    Read the article

  • Problem retrieving values from Zend_Form_SubForms - no values returned

    - by anu iyer
    I have a Zend_Form that has 4 or more subforms. /** Code Snippet **/ $bigForm = new Zend_Form(); $littleForm1 = new Form_LittleForm1(); $littleForm1->setMethod('post'); $littleForm2 = new Form_LittleForm2(); $littleForm2->setMethod('post'); $bigForm->addSubForm($littleForm1,'littleForm1',0); $bigForm->addSubForm($littleForm2,'littleForm2',0); On clicking the 'submit' button, I'm trying to print out the values entered into the forms, like so: /** Code snippet, currently not validating, just printing **/ if($this-_request-getPost()){ $formData = array(); foreach($bigForm->getSubForms() as $subForm){ $formData = array_merge($formData, $subForm->getValues()); } /* Testing */ echo "<pre>"; print_r($formData); echo "</pre>"; } The end result is that - all the elements in the form do get printed, but the values entered before posting the form don't get printed. Any thoughts are appreciated...I have run around circles working on this! Thanks in advance!

    Read the article

  • Assigning values to the lable through database depending on listbox values

    - by SurajVitekar
    I want to assign the values of five labels from database regarding to values selected in listbox. The db query returns single column with multiple records. Please help. I'm working with C# 2010 and MS SQL. My current code is: private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { try { String c1, c2; c1 = "NULL"; MessageBox.Show("LB index :"+listBox1.SelectedIndex.ToString()); //p = listBox1.SelectedItem.ToString(); SqlConnection con = new SqlConnection(); con.ConnectionString = "Data Source=localhost;Initial Catalog=eVoting;Integrated Security=True;Pooling=False"; con.Open(); MessageBox.Show("List bOx sect :"+listBox1.SelectedValue.ToString()); SqlCommand cmd = new SqlCommand("select Firstname from candidates where position ='" + listBox1.SelectedValue.ToString() + "'", con); int index = 0; SqlDataReader reader = cmd.ExecuteReader(); while(reader.Read()) { if (index == 0) { c1 = reader[index].ToString(); radioButton1.Text = c1; } if (index == 1) { c1 = reader[index].ToString(); radioButton2.Text = c1; } if (index == 2) { c1 = reader[index].ToString(); radioButton3.Text = c1; } if (index == 3) { c1 = reader[index].ToString(); radioButton4.Text = c1; } if (index == 4) { c1 = reader[index].ToString(); radioButton4.Text = c1; } if (index == 5) { c1 = reader[index].ToString(); radioButton5.Text = c1; } MessageBox.Show("c1 :" + c1); index++; } } catch (Exception E) { } }

    Read the article

  • if there is any technique to insert values into multiple tables in sql Server 2008 Database?

    - by Krishanu Dey
    I just wanted to know, if there is any technique to insert values into multiple tables in sql Server 2008 Database? I've got the following cmd.CommandText = "Insert into tb1 (col1, col2, col3) values (@col1, @col2, @col3); Insert into tb2 (col1, col2, col3) values (@col11, @col12, @col13);"; cmd.Parameters.AddWithValue("col1","val1"); cmd.Parameters.AddWithValue("col2", "val2"); cmd.Parameters.AddWithValue("col3", "val3"); cmd.Parameters.AddWithValue("col11","val4"); cmd.Parameters.AddWithValue("col12", "val5"); cmd.Parameters.AddWithValue("col13", "val6"); But will values be inserted to "tb1" even if "Insert into tb2..." part gets an error? if yes then it is not what i wanted. i wanted that, values should not be inserted into tb1 if tb2 part gets an error. please help me out.

    Read the article

  • Default values - are they good or evil?

    - by Andrew
    The question about default values in general - default return function values, default parameter values, default logic for when something is missing, default logic for handling exceptions, default logic for handling the edge conditions etc. For a long time I considered default values to be a "pure evil" thing, something that "cloaks the catastrophe" and results in a very hard do find bugs. But recently I started to think about default values as some sort of a technical debt ... which is not a straight bad thing but something that could provide some "short term financing" get us to survive the project (how many of us could afford to buy a house without taking out the mortgage?). When I say a "short term" - I don't mean - "do something quickly first and do refactor it out later before it hits the production". No - I am talking about relying on a hardcoded default values in a production software. Granted - it could cause some issues, but what if it only going to cause a single trouble in a whole year. Again - I am talking about the "average" mainstream software here (not a software for a nuclear power station) - the average web site or a UI application for the accounting software, meaning that people lives are not at stake, nor millions of dollars. Again, from my experience, business users would rather live with the software which "works somehow", rather then wait for a perfect one. And the use of default values helps a lot if you develop a software in a RAD style. But again - the longest debug sessions I have spent were because of the bugs introduced by a default value which either stopped being "a default" along the way or because a small subsystem has recently been upgraded and as a result of this upgrade it does not handle the default correctly (e.g. empty list vs null, or null string vs empty string). So my question is - are the default values good or evil. And if they are a technical debt - how do measure up how much you can borrow so you can afford the repayments? Would really appreciate any input. Cheers. EDIT: If I am using the default values as a way to cut the corners during the development - and if the corners cutting results in a bugs and issues - what is the methodology to recover from these issues?

    Read the article

  • Validatation error "Value Error : background-position Too many values or values are not" How to so

    - by metal-gear-solid
    Why validation giving this error. How to solve? ul#navigation li#navigation-3 a.current Value Error : background-position Too many values or values are not recognized : -164px -164px -36px -164px -164px -36px This is error screen. CSS ul#navigation { height: 36px; left: 300px; list-style-image: none; list-style-position: outside; list-style-type: none; position: relative; top: 74px; width: 603px; } ul#navigation li { display: inline; } ul#navigation li a { height: 36px; float: left; text-decoration: none; } ul#navigation li a:link, ul#navigation li a:visited {font-family:Arial; color:#595959; font-size:1.1em; font-weight:bold } ul#navigation li a:hover, ul#navigation li a:active {color:#404040} ul#navigation li a span { display:block; float:left; padding-left:8px; padding-top:14px;} ul#navigation li#navigation-1 a { width: 53px; background: url(../images/menu-sprite.jpg) no-repeat 0px 0; } ul#navigation li#navigation-1 a:active, ul#navigation li#navigation-1 a:hover { background-position: 0px -36px; } ul#navigation li#navigation-1 a.current { background-position: 0px 0px -36px; } ul#navigation li#navigation-2 a { width: 111px; background: url(../images/menu-sprite.jpg) no-repeat -53px 0; } ul#navigation li#navigation-2 a:active, ul#navigation li#navigation-2 a:hover { background-position: -53px -36px; } ul#navigation li#navigation-2 a.current { background-position: -53px -53px -36px; } ul#navigation li#navigation-3 a { width: 78px; background: url(../images/menu-sprite.jpg) no-repeat -164px 0; } ul#navigation li#navigation-3 a:active, ul#navigation li#navigation-3 a:hover { background-position: -164px -36px; } ul#navigation li#navigation-3 a.current { background-position: -164px -164px -36px; } ul#navigation li#navigation-4 a { width: 100px; background: url(../images/menu-sprite.jpg) no-repeat -242px 0; } ul#navigation li#navigation-4 a:active, ul#navigation li#navigation-4 a:hover { background-position: -242px -36px; } ul#navigation li#navigation-4 a.current { background-position: -242px -242px -36px; } ul#navigation li#navigation-5 a { width: 88px; background: url(../images/menu-sprite.jpg) no-repeat -342px 0; } ul#navigation li#navigation-5 a:active, ul#navigation li#navigation-5 a:hover { background-position: -342px -36px; } ul#navigation li#navigation-5 a.current { background-position: -342px -342px -36px; } ul#navigation li#navigation-6 a { width: 96px; background: url(../images/menu-sprite.jpg) no-repeat -430px 0; } ul#navigation li#navigation-6 a:active, ul#navigation li#navigation-6 a:hover { background-position: -430px -36px; } ul#navigation li#navigation-6 a.current { background-position: -430px -430px -36px; } ul#navigation li#navigation-7 a { width: 77px; background: url(../images/menu-sprite.jpg) no-repeat -526px 0; } ul#navigation li#navigation-7 a:active, ul#navigation li#navigation-7 a:hover { background-position: -526px -36px; } ul#navigation li#navigation-7 a.current { background-position: -526px -526px -36px; }

    Read the article

  • how to change string values in dictionary to int values

    - by tom smith
    I have a dictionary such as: {'Sun': {'Satellites': 'Mercury,Venus,Earth,Mars,Jupiter,Saturn,Uranus,Neptune,Ceres,Pluto,Haumea,Makemake,Eris', 'Orbital Radius': '0', 'Object': 'Sun', 'RootObject': 'Sun', 'Radius': '20890260'}, 'Earth': {'Period': '365.256363004', 'Satellites': 'Moon', 'Orbital Radius': '77098290', 'Radius': '63710.41000.0', 'Object': 'Earth'}, 'Moon': {'Period': '27.321582', 'Orbital Radius': '18128500', 'Radius': '1737000.10', 'Object': 'Moon'}} I am wondering how to change just the number values to ints instead of strings. def read_next_object(file): obj = {} for line in file: if not line.strip(): continue line = line.strip() key, val = line.split(": ") if key in obj and key == "Object": yield obj obj = {} obj[key] = val yield obj planets = {} with open( "smallsolar.txt", 'r') as f: for obj in read_next_object(f): planets[obj["Object"]] = obj print(planets)

    Read the article

  • Haskell - mapping the odd placed values and the even placed values differently

    - by Abstract
    Hey guys, is there an easy way. To take a list of numbers, say 123456. Then multiply the odd placed by three and the even placed by 1. i.e. (1 * 3) + (2 * 1) + (3 * 3) + (4*1) + (5*3) + (6*1) i was thinking the map function somewhere along the lines. But i don't know how to map *3 to just the odd placed values. Oh and if you could give me the version not in prelude that would be great like the actual function or functions, as if its being imported from an external haskell file Thanks for the help

    Read the article

  • Sum up values in SQL once all values are available

    - by James Brown
    I have events flowing into a MySQL database and I need to group and sum the events to transactions and store away into another table. The data looks like: +----+---------+------+-------+ | id | transid | code | value | +----+---------+------+-------+ | 1 | 1 | b | 12 | | 2 | 1 | i | 23 | | 3 | 2 | b | 34 | | 4 | 1 | e | 45 | | 5 | 3 | b | 56 | | 6 | 2 | i | 67 | | 7 | 2 | e | 78 | | 8 | 3 | i | 89 | | 9 | 3 | i | 90 | +----+---------+------+-------+ The events arrive in batches and I would like to create the transaction by summing up the values for each transid, like: select transid, sum(value) from eventtable group by transid; but only after all the events for that transid have arrived. That is determined by the event with the code e (b for the beginning, e for the end and i for varying amount of intermediates). Being a novice in SQL, how could I implement the requirement for the existance of the end code before the summing?

    Read the article

  • Replace duplicate values in array with new randomly generated values

    - by RussellDias
    I have below a function (created by Gordon in a previous question that went unanswered) that creates an array with n amount of values. The sum of the array is equal to $max. function randomDistinctPartition($n, $max) { $partition= array(); for($i=1; $i < $n; $i++) { $maxSingleNumber = $max - $n; $partition[] = $number = rand(1, $maxSingleNumber); } $max -= $number; } $partition[] = $max; return $partition; } For example: If I set $n = 4 and $max = 30. Then I should get the following. array(5, 7, 10, 8); However, this function does not take into account duplicates and 0s. What I would like - and have been trying to accomplish - is to generate an array with unique numbers that add up to my predetermined variable $max. No Duplicate numbers and No 0 and/or negative integers.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >