Search Results

Search found 17068 results on 683 pages for 'merge array'.

Page 17/683 | < Previous Page | 13 14 15 16 17 18 19 20 21 22 23 24  | Next Page >

  • Stairway to T-SQL DML Level 12: Using the MERGE Statement

    The final level of this stairway looks at the MERGE statement in detail, focusing on how to perform insert, update and delete logic using the MERGE statement. An accidental DBA? Try SQL MonitorUse the 30-day full product free trial to get easy-to-understand insights into SQL Server, and get suggestions on how to solve the type of issues that are uncovered. Begin your free trial.

    Read the article

  • [R] Merge multiple data frames - Error in match.names(clabs, names(xi)) : names do not match previou

    - by Jasmine
    Hi all- I'm getting some really bizarre stuff while trying to merge multiple data frames. Help! I need to merge a bunch of data frames by the columns 'RID' and 'VISCODE'. Here is an example of what it looks like: d1 = data.frame(ID = sample(9, 1:100), RID = c(2, 5, 7, 9, 12), VISCODE = rep('bl', 5), value1 = rep(16, 5)) d2 = data.frame(ID = sample(9, 1:100), RID = c(2, 2, 2, 5, 5, 5, 7, 7, 7), VISCODE = rep(c('bl', 'm06', 'm12'), 3), value2 = rep(100, 9)) d3 = data.frame(ID = sample(9, 1:100), RID = c(2, 2, 2, 5, 5, 5, 9,9,9), VISCODE = rep(c('bl', 'm06', 'm12'), 3), value3 = rep("a", 9), values3.5 = rep("c", 9)) d4 = data.frame(ID =sample(8, 1:100), RID = c(2, 2, 5, 5, 5, 7, 7, 7, 9), VISCODE = c(c('bl', 'm12'), rep(c('bl', 'm06', 'm12'), 2), 'bl'), value4 = rep("b", 9)) dataList = list(d1, d2, d3, d4) I looked at the answers to the question titled "Merge several data.frames into one data.frame with a loop." I used the reduce method suggested there as well as a loop I wrote: try1 = mymerge(dataList) try2 <- Reduce(function(x, y) merge(x, y, all= TRUE, by=c("RID", "VISCODE")), dataList, accumulate=F) where dataList is a list of data frames and mymerge is: mymerge = function(dataList){ L = length(dataList) mdat = dataList[[1]] for(i in 2:L){ mdat = merge(mdat, dataList[[i]], by.x = c("RID", "VISCODE"), by.y = c("RID", "VISCODE"), all = TRUE) } mdat } For my test data and subsets of my real data, both of these work fine and produce exactly the same results. However, when I use larger subsets of my data, they both break down and give me the following error: Error in match.names(clabs, names(xi)) : names do not match previous names. The really weird thing is that using this works: dataList = list(demog[1:50,], neurobat[1:50,], apoe[1:50,], mmse[1:50,], faq[1:47, ]) And using this fails: dataList = list(demog[1:50,], neurobat[1:50,], apoe[1:50,], mmse[1:50,], faq[1:48, ]) As far as I can tell, there is nothing special about row 48 of faq. Likewise, using this works: dataList = list(demog[1:50,], neurobat[1:50,], apoe[1:50,], mmse[1:50,], pdx[1:47, ]) And using this fails: dataList = list(demog[1:50,], neurobat[1:50,], apoe[1:50,], mmse[1:50,], pdx[1:48, ]) Row 48 in faq and row 48 in pdx have the same values for RID and VISCODE, the same value for EXAMDATE (something I'm not matching on) and different values for ID (another thing I'm not matching on). Besides the matching RID and VISCODE, I see anything special about them. They don't share any other variable names. This same scenario occurs elsewhere in the data without problems. To add icing on the complication cake, this doesn't even work: dataList = list(demog[1:50,], neurobat[1:50,], apoe[1:50,], mmse[1:50,], faq[1:48, 2:3]) where columns 2 and 3 are "RID" and "VISCODE". 48 isn't even the magic number because this works: dataList = list(demog[1:500,], neurobat[1:500,], apoe[1:500,], mmse[1:457,]) while using mmse[1:458, ] fails. I can't seem to come up with test data that causes the problem. Has anyone had this problem before? Any better ideas on how to merge? Thanks for your help! Jasmine

    Read the article

  • Excel formula - sometimes array formula, sometimes not

    - by Jonas
    I want to write some data to an Excel file, and I want the first page to show a summary of the data that are spread all over the sheets. The individual data items on a sheet can be included or excluded, and I want the summary to be calculated only on the included values. Thus, I thought I'd use a formula like this to show, for example, an average (for which empty fields shouldn't be counted, either): =AVERAGE(IF('dataSheet1'!$B:$B=1,IF('dataSheet1'!$I:$I<>"",'dataSheet1'!$I:$I,""),"")) If I have this formula in dataSheet1, everything works fine. If I have this formula in the summary sheet, I need to enter it as an array formula, and I have to specify the exact ranges to make it work. Is there a way (aside from adding the average in dataSheet, and then referencing the result in summary) to make the formula work without having it turn into an array formula?

    Read the article

  • PHP - Counting matching arrays in array

    - by Sergio
    hi there, I have an array structure that looks like this: Array ( [0] => Array ( [type] => image [data] => Array ( [id] => 1 [alias] => test [caption] => no caption [width] => 200 [height] => 200 ) ) [1] => Array ( [type] => image [data] => Array ( [id] => 2 [alias] => test2 [caption] => hello there [width] => 150 [height] => 150 ) ) ) My question is, how can I get a count of the number of embedded arrays that have their type set as image (or anything else for that matter)? In practise this value can vary. So, the above array would give me an answer of 2. Thanks

    Read the article

  • Is it possible to override the behavior of a merge module.

    - by Kragen
    Supposing I have a merge module that installs a file "MyFile.txt" to a certain location, and that I wish to use that merge module, however I want to supply a different copy of "MyFile.txt" from the one supplied with the merge module. Is it possible to do this? (And for bonus points how can I do this using Wix)

    Read the article

  • 2 dimensional array

    - by ankit
    we have these arrays.... $cities = array("nagpur","kanpur","delhi","chd","Noida","mumbai","nagpur"); $names = array("munish","imteyaz","ram","shyam","ankit","Rahul","mohan"); now i want a 2 dimensional array with name of city as key and all the corresponding names as its values. <?php $cities = array("nagpur","kanpur","nagpur","delhi","kanpur"); $names = array("ankit","atul","aman","amit","manu"); foreach ($cities as $i => $value) { echo "\n"; echo $value; $city=$value; $k=0; foreach ($cities as $ii => $m) { If($city==$m) { echo$names[$ii] ; $final[$i][$k]=$names[$ii]; $arr = array($city => array($k =>$names[$ii] )); $k++; } } echo"\n<tr></tr>"; } wat i tried is this.but it doesnt work.help me

    Read the article

  • Unable to access value of nested array element

    - by John Conde
    I'm having an issue getting the value of a nested array element. Here's what I've got: print_r($environment); // Outputs Array ( [0] => Array ( ['parameter'] => Vibration ['conditions'] => 204 ['method'] => D ) [1] => Array ( ['parameter'] => Immersion ['conditions'] => 104 ['method'] => B ) [2] => Array ( ['parameter'] => Shock ['conditions'] => 213 ['method'] => I ) [3] => Array ( ['parameter'] => Humidity ['conditions'] => 106 ['method'] => - ) ) print_r($environment[0]); // Outputs Array ( ['parameter'] => Vibration ['conditions'] => 204 ['method'] => D ) echo $environment[0]['parameter']; // Nothing Maybe I've been looking at this for too long. Any ideas would be greatly appreciated.

    Read the article

  • In .NET, What Is Fastest Way to Initialize Multi-Dimensional Array to Non-Default Value

    - by AMissico
    How do I initialize a multi-dimensional array of a primitive type as fast as possible? I am stuck with using multi-dimensional arrays. My problem is performance. The following routine initializes a 100x100 array in approx. 500 ticks. Removing the int.MaxValue initialization results in approx. 180 ticks just for the looping. Approximately 100 ticks to create the array without looping and without initializing to int.MaxValue. Routines similiar to this are called a few tens-of-thousands to several million times. I am open to suggestions on how to optimize this non-default initialization of an array. One idea I had is to use a smaller primitive type when available. For instance, using byte instead of int, saves 100 ticks. I would be happy with this, but I am hoping that I don't have to change the primitive data type. public int[,] CreateArray(Size size) { int[,] array = new int[size.Width, size.Height]; for (int x = 0; x < size.Width; x++) { for (int y = 0; y < size.Height; y++) { array[x, y] = int.MaxValue; } } return array; }

    Read the article

  • Recursive N-way merge/diff algorithm for directory trees?

    - by BobMcGee
    What algorithms or Java libraries are available to do N-way, recursive diff/merge of directories? I need to be able to generate a list of folder trees that have many identical files, and have subdirectories with many similar files. I want to be able to use 2-way merge operations to quickly remove as much redundancy as possible. Goals: Find pairs of directories that have many similar files between them. Generate short list of directory pairs that can be synchronized with 2-way merge to eliminate duplicates Should operate recursively (there may be nested duplicates of higher-level directories) Run time and storage should be O(n log n) in numbers of directories and files Should be able to use an embedded DB or page to disk for processing more files than fit in memory (100,000+). Optional: generate an ancestry and change-set between folders Optional: sort the merge operations by how many duplicates they can elliminate I know how to use hashes to find duplicate files in roughly O(n) space, but I'm at a loss for how to go from this to finding partially overlapping sets between folders and their children. EDIT: some clarification The tricky part is the difference between "exact same" contents (otherwise hashing file hashes would work) and "similar" (which will not). Basically, I want to feed this algorithm at a set of directories and have it return a set of 2-way merge operations I can perform in order to reduce duplicates as much as possible with as few conflicts possible. It's effectively constructing an ancestry tree showing which folders are derived from each other. The end goal is to let me incorporate a bunch of different folders into one common tree. For example, I may have a folder holding programming projects, and then copy some of its contents to another computer to work on it. Then I might back up and intermediate version to flash drive. Except I may have 8 or 10 different versions, with slightly different organizational structures or folder names. I need to be able to merge them one step at a time, so I can chose how to incorporate changes at each step of the way. This is actually more or less what I intend to do with my utility (bring together a bunch of scattered backups from different points in time). I figure if I can do it right I may as well release it as a small open source util. I think the same tricks might be useful for comparing XML trees though.

    Read the article

  • Copy a multi-dimentional array by Value (not by reference) in PHP.

    - by Simon R
    Language: PHP I have a form which asks users for their educational details, course details and technical details. When the form is submitted the page goes to a different page to run processes on the information and save parts to a database. HOWEVER(!) I then need to return the page back to the original page, where having access to the original post information is needed. I thought it would be simple to copy (by value) the multi-dimensional (md) $_POST array to $_SESSION['post'] session_start(); $_SESSION['post'] = $_POST; However this only appears to place the top level of the array into $_SESSION['post'] not doing anything with the children/sub-arrays. An abbreviated form of the md $_POST array is as follows: Array ( [formid] = 2 [edu] = Array ( ['id'] = Array ( [1] = new_1 [2] = new_2 ) ['nameOfInstitution'] = Array ( [1] = 1 [2] = 2 ) ['qualification'] = Array ( [1] = blah [2] = blah ) ['grade'] = Array ( [1] = blah [2] = blah ) ) [vID] = 61 [Submit] = Save and Continue ) If I echo $_SESSION['post']['formid'] it writes "2", and if I echo $_SESSION['post']['edu'] it returns "Array". If I check that edu is an array (is_array($_SESSION['post']['edu])) it returns true. If I echo $_SESSION['post']['edu']['id'] it returns array, but when checked (is_array($_SESSION['post']['edu]['id'])) it returns false and I cannot echo out any of the elements. How do I successfully copy (by value, not by reference) the whole array (including its children) to an new array?

    Read the article

  • Reverse alphabetic sort multidimensional PHP array maintain key

    - by useyourillusiontoo
    I'm dying here, any help would be great. I've got an array that I can sort a-z on the value of a specific key but cannot sort in reverse z-a. sample of my array which i'd like to sort by ProjectName (z-a): Array ( [0] => Array ( [count] => 1 [ProjectName] => bbcjob [Postcode] => 53.471922,-2.2996078 [Sector] => Public ) [1] => Array ( [count] => 1 [ProjectName] => commercial enterprise zone [Postcode] => 53.3742081,-1.4926439 [Sector] => Public ) [2] => Array ( [count] => 1 [ProjectName] => Monkeys eat chips [Postcode] => 51.5141492,-0.2271227 [Sector] => Private the desired results would be to maintain the entire array key - value structure but with the order: Monkeys eat chips Commericial enterprise zone bbcjob I hope this makes sense

    Read the article

  • Android: Defined array resource not found ?!

    - by David
    Hi, i have a strange (?) error in my android application. I have defined some arrays in values/arrays.xml the following way: <?xml version="1.0" encoding="utf-8"?> <resources> <array name="perimeter"> <item>10 miles</item> <item>20 miles</item> <item>30 miles</item> </array> <array name="regvalues"> <item>1</item> <item>2</item> <item>3</item> </array> </resources> Now I want to use them in a ListPreference for a PreferenceActivity (defined by an xml file). So i set android:entries="@array/perimeter" android:entryValues="@array/regvalues" for this ListPreference. When I try to use this on my device the app crashes. (NullPointer in Dialog.close()) If I try to use the regvalues-items as Entries for the ListPreference i get a NullPointer in ArrayAdapter.createViewFromResource(int, View, ViewGroup, int) line: 355 So there seems to be sth wrong with the regvalues array. But what ?!? Eclipse shows me no errors at compile time. So everything in the xml-file and java-code is written correctly and there are no typos. Where is the problem?!?

    Read the article

  • php how to serialize array of objects?

    - by hequ
    Hello, I have small class called 'Call' and I need to store these calls into a flat file. I've made another class called 'CallStorage' which contains an array where I put these calls into. My problem is that I would like to store this array to disk so I could later read it back and get the calls from that array. I've tried to achieve this using serialize() and unserialize() but these seems to act somehow strange and part of the information gets lost. This is what I'm doing: //write array to disk $filename = $path . 'calls-' . $today; $serialized = serialize($this->array); $fp = fopen($filename, 'a'); fwrite($fp, $serialized); fclose($fp); //read array from serialized file $filename = $path . 'calls-' . $today; if (file_exists($filename)) { $handle = fopen($filename, 'r'); $contents = fread($handle, filesize($filename)); fclose($handle); $unserialized = unserialize($contents); $this->setArray($unserialized); } Can someone see what I'm doing wrong, or what. I've also tried to serialize and write arrays that contains plain strings. I didn't manage to get that working either.. I have a Java background so I just can't see why I couldn't just write an array to disk if it's serialized. :)

    Read the article

  • Merge two data frames together that have the same variable names and data types

    - by Brandon
    I have tried the merge function to merge two csv files that I imported. They both have the same variable names and data types but each time I run merge all that I get is an object that contains the names of the two data frames. I have tried the following: # ex1 obj <- merge(obj1, obj2, by=obj) # ex2 obj <- merge(obj1, obj2, all) and several other iterations of the above. Is merge the correct function? If so, what am I doing wrong?

    Read the article

  • For each result in MySQL query, push to array (complicated)

    - by Dylan Taylor
    Okay, here's what I'm trying to do. I am running a MySQL query for the most recent posts. For each of the returned rows, I need to push the ID of the row to an array, then within that ID in the array, I need to add more data from the rows. A multi-dimensional array. Here's my code thus far. $query = "SELECT * FROM posts ORDER BY id DESC LIMIT 10"; $result = mysql_query($query); while($row = mysql_fetch_array($result)){ $id = $row["id"]; $post_title = $row["title"]; $post_text = $row["text"]; $post_tags = $row["tags"]; $post_category = $row["category"]; $post_date = $row["date"]; } As you can see I haven't done anything with arrays yet. Here's an ideal structure I'm looking for, just incase you're confused. The master array I guess you could call it. We'll just call this array $posts. Within this array, I have one array for each row returned in my MySQL query. Within those arrays there is the $post_title, $post_text, etc. How do I do this? I'm so confused.. an example would be really appreciated. -Dylan

    Read the article

  • Sorting a multidimensional array in objective-c

    - by Zen_silence
    Hello, I'm trying to sort a multidimensional array in objective-c i know that i can sort a single dimensional array using the line of code below: NSArray *sortedArray = [someArray sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)]; I can't seem to figure out how to sort a 2D array like the one below: ( ("SOME_URL", "SOME_STORY_TITLE", "SOME_CATEGORY"), ("SOME_URL", "SOME_STORY_TITLE", "SOME_CATEGORY"), ("SOME_URL", "SOME_STORY_TITLE", "SOME_CATEGORY") ); If someone could provide me code that would sort the array by SOME_CATEGORY it would be of great help to me. Thanks, Zen_Silence

    Read the article

  • Java HashSet<Integer> to int array

    - by jackweeden
    I've got a HashSet with a bunch of (you guessed it) integers in it. I want to turn it into an array, but calling hashset.toArray(); returns an array of Object type. This is fine, but is there a better way to cast it to an array of int, other than iterating through every element manually? A method I want to pass it to void doSomething(int[] arr) Won't accept the Object[] array, even if I try casting it like doSomething((int[]) hashSet.toArray());

    Read the article

  • Perl, array referencing

    - by Mike
    Consider this Perl code my @a=[[1]]; print $a[0][0] . "\n"; **output** ARRAY(0x229e8) Why does it print an Array instead of 1? I would have expected @a to create an array of size 1 with a reference to a second array containing only one element, 1

    Read the article

  • from one-dimensional to two-dimensional array

    - by Thijs
    Hi again, I have this PHP one dimensional array: Array ( [Female--N] => 11 [Male--N] => 11 [Humans--N] => 11 [Adult--N] => 8 [Adolescent--N] => 8 [Reaction Time-physiology--N] => 6 [Acoustic Stimulation-methods--N] => 6 [Schizophrenia-genetics--Y] => 5 [Motion Perception--N] => 3 ) And i want a new array from this that looks like (i think this tow-dimensional..?): Array ( [Female][N] => 11 [Male][N] => 11 [Humans][N] => 11 [Adult][N] => 8 [Adolescent][N] => 8 [Reaction Time-physiology][N] => 6 [Acoustic Stimulation-methods][N] => 6 [Schizophrenia-genetics][Y] => 5 [Motion Perception][N] => 3 ) Can i use split method on key elements? Little bit harder... i also need to split on the single '_' underscore, i did this to prevent the columns getting mixed up... But the example below doesn't do the job right... $new_array = array(); foreach($MeshtagsArray as $key => $value) { $parts = explode('__', $key, 2); $parts2 = explode('_', $key, 2); $new_array[] = array( 'discriptor' => $parts[0], 'qualifier' => $parts2[1], 'major' => $parts[1], '#occurence' => $value ); So the output should be something like: [0] => Array ( [discriptor] => Female [qualifier] => [major] => N [#occurence] => 11 ........ [5] => Array ( [discriptor] => Reaction Time [qualifier] => physiology [major] => N [#occurence] => 6 Best regards, Thijs

    Read the article

  • list or container O(1)-ish insertion/deletion performance, with array semantics

    - by Chris Kaminski
    I'm looking for a collection that offers list semantics, but also allows array semantics. Say I have a list with the following items: apple orange carrot pear then my container array would: container[0] == apple container[1] == orangle container[2] == carrot Then say I delete the orange element: container[0] == apple container[1] == carrot I don't particularly care if sort order is maintained, I'd just like the array values to function as accelerators to the list items, and I want to collapse gaps in the array without having to do an explicit resizing.

    Read the article

  • Replace string key of PHP array

    - by poru
    Hello, I have an array in PHP which looks like that: $test = array('3' => 5); How could I replace the stringed array key 3? I tried: $test['3'] = "New value" but it don't work, it look like that after that: array('3' => 5, 3 => "New value")

    Read the article

  • declare or convert a string to array format

    - by Jamex
    Hi, How to convert a string format into an array format? I have a string, $string = 'abcde' I want to convert it to a 1 element array $string[0] = 'abcde' Is there a built in function for this task?? or the shortest way is to $string = 'abcde'; $array[0] = $string; $string = $array; TIA

    Read the article

< Previous Page | 13 14 15 16 17 18 19 20 21 22 23 24  | Next Page >