Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data stored as Objects instead of Arrays #3

Open
GoogleCodeExporter opened this issue Aug 17, 2015 · 0 comments
Open

Data stored as Objects instead of Arrays #3

GoogleCodeExporter opened this issue Aug 17, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

As AS3 is an OOP language, I find it odd that you chose to store the data in 
Arrays. The data would be much easier to work with if you would store the data 
as an Array filled with Objects, that have all the properties the header Array 
has.

In my own instance of csvlib I've added these two functions, I hope you will 
consider implementing something similair.

public function decodeToObject():void {
            decode();
            var dataArray:Array = data as Array;
            var voList:Array = [];
            var i:int;
            var length:int = header.length;
            for(i = 0; i <length; i++){
                voList.push(toObject(dataArray[i]))
            }

            data = voList;
        }

        public function toObject(entry:Array):Object {
            //the length of the entry should be the same as that of the header array

            var vo:Object = new Object();
            var i:int;
            var length:int = header.length;
            var propertyName:String;
            for(i = 0; i < length; i++){
                propertyName = header[i];       
                vo[propertyName] = entry[i];
            }

            return vo;
        }


Original issue reported on code.google.com by t...@newnomads.nl on 19 May 2011 at 1:05

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant