Questions tagged [flatten]

Flattening refers to either reducing a multi-dimensional array to a single dimension or to reducing a class and class methods to handle based function calls.

1554 questions
0
votes
5 answers

Flatten multidimensional array to 3 levels preserving the first level keys

I have a nested multidimensional array like this: $array = [ 1 => [ [ ['catName' => 'Villes', 'catUrl' => 'villes', 'parent' => 151], [ ['catName' => 'Administratif', 'catUrl' => 'territoire',…
Kyobul
  • 759
  • 1
  • 7
  • 17
0
votes
3 answers

Flatten nested dictionaries while checking content

I have a dictionary like this: source = { 'Section 1' : { 'range' : [0, 200], 'template' : 'ID-LOA-XXX', 'nomenclature': True }, 'Section 2' : { 'range' : [201, 800], 'template' …
Rody Oldenhuis
  • 37,726
  • 7
  • 50
  • 96
0
votes
2 answers

Binding a flattern EF entity over GridView and allow sync with repositories

I'm using for the first time Entity Framework in a complex grid databinding situation and i need some strategies to accomplish this task. I've got these POCO classes autogenerated by "EF POCO reverse code first" (the same for mappings) and for each…
GiveEmTheBoot
  • 534
  • 9
  • 24
0
votes
2 answers

Cakephp _serialize - how to transform multiple model error messages into simple JSON array?

I'm using CakePHP _serialize function to API response output. In case of some validation error on model is returned message which describes error in JSON output. Code is like this: $status = 'NOK'; $errors =…
redrom
  • 11,502
  • 31
  • 157
  • 264
0
votes
1 answer

Underscore _.flatten with prefix of the to be flatten object

I need to flatten an object like this: { ProductId: { Id: "123456-1234-1234-1234-123456789012", Type: "product", Name: "Product" } } to look like { ProductId_Id: "123456-1234-1234-1234-123456789012", ProductId_Type: "product", …
hinogi
  • 36
  • 3
0
votes
1 answer

Flatten Xml Using Xslt, Creating Nodes from Values, Dashes for Spaces

Seen lots of similar questions here on StackOverflow, and I've been trying to follow those all day to get my specific situation figured out, but little luck. I want to take this xml: 123 Bob
Marvin
  • 569
  • 6
  • 23
0
votes
1 answer

List structure size function, difficulty with code

I need to write a function(size) that gets a list structure and recieves its size. The size is the number of pair brackets and the number of ints in the list structure. For example: size([[[14],[23,[14]]]])= 8 (5 pair brackets, 3 ints) I wrote a…
user2751595
  • 337
  • 3
  • 13
0
votes
1 answer

Rails flatten quick

I'm loading the configuration from a YAML file. I have a hash that looks like this: {:first=>{:abc=>[["one", "two", "three"]], :def => [["one", "two", "three"]]}, :second=>{:abc=>[["one", "two", "three"]]}} But I would like to get:…
Dmitri
  • 2,451
  • 6
  • 35
  • 55
0
votes
0 answers

PigScript - Join after multiple operations (GROUP and FLATTEN)

I'm new to programming in PIG and I have a relation with multiple fields (I'm simplifying the schema in this example below). I'm doing some calculations multiple times, and at the end I'm trying to join the results. But I get no results, and if I…
0
votes
4 answers

Make 2D array 1-dimensional in Python

I was trying to "flatten" an array, to convert it to 1 single dimension set of items. I work with the append command and I get this: [['X', 'X'],['ff','ff','ff','ff','ff']] But I would prefer to have the elements sorted…
Ramon Blanquer
  • 392
  • 3
  • 8
  • 22
0
votes
1 answer

How to flatten nested arrays based on a key of its members

I have the following JSON object: { "name": "Womens", "position": 1, "url": "/collections/womens-all", "submenus": [ { "name": "Apparel", "position": 1, "url": "/collections/womens-apparel-all", "submenus": [ …
0
votes
1 answer

Flatten table rows by combining certain values into columns

I'm trying to build a view for reporting purposes and am having trouble flattening results to display what would normally multiple rows into a single row, by combining a few values into columns. Each organization has two administrators, and would…
sharknado
  • 53
  • 7
0
votes
1 answer

Projecting aggregated data to flat one

How can I get from this: var props = new List(); props.Add(new RoomProperties(new[] {3, 4, 5}, new string[] {"AC", "WC"})); props.Add(new RoomProperties(new[] {2}, new string[] {"AC", "TV"})); props.Add(new RoomProperties(new[] {3},…
rene98c
  • 21
  • 3
0
votes
1 answer

Unexpected error in BigQuery comparisons

I was running the following query against the public dataset github_nested, and I got an error: "Unexpected. Please try again" SELECT IF(payload.pages.action < 'a', 3, -3) test FROM FLATTEN([publicdata:samples.github_nested], payload.pages) But…
Randy
  • 23
  • 4
0
votes
1 answer

compare flatten index with own index

I'm creating an array within an array. (paragraphs within articles). Then i flatten this into one array. Let's call this ARRAY_COMPARISON_REFERENCE Next to that I am making an array that gives a number to every next paragraph. The first paragraph of…
Seeb
  • 199
  • 4
  • 16