flatten

Flattening one-to-many relationship in Django

I have a few model classes with basic one-to-many relationships. For example, a book has many recipes, and each recipe has many ingredients: class Book(models.Model): name = models.CharField(max_length=64) class Recipe(models.Model): book = models.ForeignKey(Book) name = models.CharField(max_length=64) class Ingredient(mo...

Flatten PDFs in PHP?

Hi, I wondered if it was possible to flatten PDFs using PHP? I use fpdf to create and collate from a collection of PDFs however when php has processed it some information is missing such as the comments. I get sent several thousand PDFs every month that go on the companys website. I do need to display the comments? I Know I can flatten...

Flatten Adjacency List Hierarchy To A List Of All Paths

I have a Table that stores Hierarchical information using the Adjacency List model. (uses a self referential key - example below. This Table may look familiar): category_id name parent ----------- -------------------- ----------- 1 ELECTRONICS NULL 2 TELEVISIONS 1 3 TUBE ...

How to 'Flatten' multiple UIImageViews into ONE?

I have a feeling this is not an easy task but I need to combine or flatten a UIImageView with another UIImage view lying above it. For example: I have two UIImageViews. One of them has a UIImage of a grassy field (1200 x 1200 pixels). The other is a UIImage of a basketball (128 x 128 pixels), and it is positioned above the image of the g...

SQL flattening & dynamic query question

Firstly, I am not certain this is the best way to handle this AT ALL ... totally open to alternative solutions. Secondly, I feel like I'm missing the obvious ... but I'm still missing it so not to proud to ask! UPDATE: .NET 3.5 environment w/ SQL 2005, so things like dynamic linq possible, although I always tend to think of dynamic (bu...

Flattening Images in Iphone SDK

I am trying to save more then 1 image with a background image into a single image and then saving it out. I found out how to flatten the images, but the images I added on top of the background are not appearing in the correct position when flattening them. It seems like they appearing in different position with different background image...

How to Flatten a Multidimensional Array?

Is it possible, in PHP, to flatten a (bi/multi)dimensional array without using recursion or references? I'm only interested in the values so the keys can be ignored, I'm thinking in the lines of array_map() and array_values(). ...

How to flatten a List of different types in Scala?

I have 4 elements:List[List[Object]] (Objects are different in each element) that I want to zip so that I can have a List[List[obj1],List[obj2],List[obj3],List[obj4]] I tried to zip them and I obtained a nested list that I can't apply flatten to because it says: no implicit argument matching parameter type. How can I solve this? should...

How can I flatten a resultset in SSIS?

Hello, I have a requirement to "flatten" a resultset in an SSIS package - this is, take a result set consisting of a number of rows and produce a single string with the concatenated values. The result set is returned to me via a stored procedure that for a number of reasons I cannot change. I do not want to duplicate the logic into an...

Is there a built in way to get an array out of multi dim array in PHP?

(Very useful when querying DB). If I have a multy dim array [['id'=>1],['id'=>2],['id'=>34],['id'=>67]] and what I want is [1,2,34,67] I know how to do it in code, just asking if there is a built in way in PHP (or may be in PDO) to do this. ...

Append number to filenames when flattening directory structure on Linux

I have a directory structure that looks like this: /a/f.xml /b/f.xml /c/f.xml /d/f.xml What I want to do is copy all the xml files into one directory like this: /e/f_0.xml /e/f_1.xml /e/f_2.xml /e/f_3.xml How can I do that efficiently on the Linux shell? ...

Flattening XSD schema documents (HR-XML 3.0)

I have several "main" XSD documents, which import "supporting" XSD documents. These schema documents happen to be from the HR-XML 3.0 specification, in particular related to Background Screening. For the purposes of code-generation and convenient single-file schema to reference in my WSDL, I am trying to "flatten" the schema. The import...

Trying to get a single row (flattened) for a master detail table using LINQ to SQL

I have a Batch Table that has three columns ID, Name, Type and a CustomAttribute table that has three columns ID, ParentID, PropertyName and Value. The Select query is "Select Batch.ID, Batch.Name, CustomAttribute.PropertyName, CustomAttribute.Value from Batch, CustomAttribute where CustomAttribute.ParentID = Batch.ID This query will g...

Erlang : flattening a list of strings

I have a list like this: [["str1","str2"],["str3","str4"],["str5","str6"]] And I need to convert it to ["str1", "str2", "str3", "str4", "str5", "str6"] How do I do this? The problem is that I'm dealing with lists of strings, so when I do lists:flatten([["str1","str2"],["str3","str4"],["str5","str6"]]) I get "str1str2str3str4...

How can I "merge", "flatten" or "pivot" results from a query which returns multiple rows into a single result?

I have a simple query over a table, which returns results like the following: id id_type id_ref 2702 5 31 2702 16 14 2702 17 3 2702 40 1 2703 23 4 2703 23 5 2703 34 6 2704 1 14 And I would like to merge the results into a single row, for instance: id concatenation 2702...

Haskell FlatMap

I am a beginner interested in Haskell, and I have been trying to implement the flatmap (>>=) on my own to better understand it. Currently I have flatmap :: (t -> a) -> [t] -> [a] flatmap _ [] = [] flatmap f (x:xs) = f x : flatmap f xs which implements the "map" part but not the "flat". Most of the modifications I make result i...

How To Query Many-to-Many Table (one table's values becomes column headers)

Given this table structure, I want to flatten out the many-to-many relationships and make the values in the Name field of one table into column headers and the quantities from the same table into column values. The current idea which will work is to put the values into a Dictionary (hashtable) and represent this data in code but im wond...

Flatten a java project directory structure prepending the path to the file.

Hi there, I am trying to write a script (preferably in bash) to flatten a java projet directory structure prepending the path to the file. Example: | src | org | apache | file2.java | file1.java would result in: | src | org|apache|file2.java | org|file1.java The script should be recursive since the directory co...

too many fields to specify in result set of join

hi, So similar questions have been asked with not much of an answer.... I have a Stats Table related to a Branch table. The Stats records contain pc stats of a particular bank branch. Branch +Code +Name +Area ... Stats +BranchCode +IP +UpSpeed +DownSpeed ... Here is my linq query... var stats = from st in store.Stats ...

Python: flatten function works in console but not in file?

I'm doing an exercise to flatten nested lists. The code works in console but it doesn't work when its in a file. I have no idea what's going on. :( def flatten(nested): """ >>> flatten([2, 9, [2, 1, 13, 2], 8, [2, 6]]) [2, 9, 2, 1, 13, 2, 8, 2, 6] >>> flatten([[9, [7, 1, 13, 2], 8], [7, 6]]) ...