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.
Questions tagged [flatten]
1554 questions
0
votes
2 answers
flattening list if sublists are same length
I've got a list such as [[1,2], [3,4], [5,6], [7,8], [9,10]] . I want to get [1,2,3,4,5,6,7,8,9,10].
This question gives some very good options for flattening lists in general. The answers given there work with variable length sublists. Here…

Joel
- 22,598
- 6
- 69
- 93
0
votes
1 answer
Converting large, ill-formatted .json file to csv
I have very little experience with python and .json files. I want to convert a large .json file that I recieved from someone else into a .csv file for use in excel.
The file is formatted as such:
{
"bedrock": {
"basinAge": "",
"basinName":…

GAP
- 1
- 1
0
votes
2 answers
prolog sum list using atomic
I am trying to perform a sumList function in prolog that takes the
input: sumList([1,[2,3],[4],5],X). and returns X=15.
I understand how to sum a simple list and a list of lists(ie [1,2,3,4,5] & [[1,2,3],[4,5]]) but i am getting errors because i am…

Laura
- 3
- 1
0
votes
2 answers
Haskell - Flattening Objects of Lists
I am dealing with first order logic propositions expressions as objects:
data Prop
= Atom String
| Var String
| Pred String [Prop]
| Not Prop
| And [Prop]
| Or [Prop]
| Nil
deriving (Show,Eq)
I take an expression as…

SalmaFG
- 2,022
- 3
- 23
- 36
0
votes
1 answer
Python: Twitter API tweets/search: Flatten nested dictionary to columns
Python Code to Flatten Twitter Output to Flat Columnar for .csv / Tableau / SQL
def test_for_entity(root,key,entity_value):
# test if list is entity
parent_key = root.split(".")[-1:][0]
if 'entities'in root.split("."):
# Entities…

Alexander McFarlane
- 10,643
- 9
- 59
- 100
0
votes
2 answers
VBA excel macro to process 5000 rows and 5 columns
I am using Excel 2007 and have 5000 statements in Range A1:A5000 and four alternatives for each statement in range B1:E5000. I want to convert it to another slyle where all data comes in range G1:25000 where all four alternatives will come under…

Mumbai CabinCrew
- 341
- 2
- 4
- 14
0
votes
2 answers
Flattening a parent/child object-chain, merging values along the way
We have been staring at this problem for ages, losing valuable time.
We have these objects, lets call them Components. Our application allows you to create a new Component, based on an existing Component.
All values of the parent are 'inherited'…

Fred Fickleberry III
- 2,439
- 4
- 34
- 50
0
votes
0 answers
How can I optimise flatten operation?
I have a pig script that calculates 17 different outputs and merges them at the end.
To merge the data, I used cogroup operation.
Since cogroup output contains join identifier for each input, I have to get rid of some unnecesary columns.
So, there…

FIDIL
- 117
- 1
- 4
- 14
0
votes
1 answer
How to flatten a RDD?
I am fairly new to Spark and using Java to do functional programming with Casandra as datasource.
As an output of a map task I getting a list of strings.
JavaRDD
- > crows = sessions.map(new Function

UniLocal
- 79
- 12
0
votes
1 answer
How do you flatten a 3D array?
I have a 3D array that contains integer values for each different block in my game; int[x][y][z] = blockid;
I need to flatten the array into a one dimensional array; int[VALUE] = blockid;
I have looked through the site for an answer most of the…

ABOODYFJ
- 30
- 1
- 9
0
votes
2 answers
How can I flatten this result set to have the parents and children as all one level?
I'm trying to flatten this array such that the child is the same level as the parent. I've tried solutions from other StackOverflow questions like this and this, but to no avail. Any ideas?
(int) 3 => object() {
"new" => false,
"properties"…

Isaac Askew
- 1,281
- 2
- 17
- 30
0
votes
1 answer
convert 3 dimensional array to a 2 dimensional array
I have this byte array:
byte[,,] somedata = new byte[100,150,3];
~somedata is now populated by an external input.
I want to use the values in just this:
byte[,] useThisDataOnly = new byte[100,150];
Presently, I use this:
foreach (int x=0,x< 100;…

Andrew Simpson
- 6,883
- 11
- 79
- 179
0
votes
2 answers
Count and flatten in pig
Hi I have a data like this :
{"user_id": "kim95", "type": "Book", "title": "Modern Database Systems: The Object Model, Interoperability, and Beyond.", "year": "1995", "publisher": "ACM Press and Addison-Wesley", "authors": [{"name":"null"}],…

moubert
- 262
- 5
- 16
0
votes
1 answer
Pig flatten error
I tried this script for my nested data :
`books = load 'data/book-seded-workings-reduced.json'
using…

moubert
- 262
- 5
- 16