Created
January 23, 2019 07:18
-
-
Save BastinRobin/bb5655d8355398fca1fcd07f1bd4bd90 to your computer and use it in GitHub Desktop.
List Transformation using Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| a = [ | |
| ["id", "name", "age", "dept"], | |
| [1, "Vishnu", 30, "PGDM"], | |
| [2, "Suresh", 30, "PGDM"], | |
| [3, "Akash", 30, "MBA"], | |
| [4, "Nabin", 30, "BBA"], | |
| [5, "Akshita", 30, "BCA"], | |
| [6, "Margo", 30, "MCA"], | |
| [7, "Robin", 30, "BSc"] | |
| ] | |
| # loop the array a | |
| headers = a.pop(0) | |
| result = [] | |
| for i in range(len(a)): | |
| temp = {} | |
| for j, name in enumerate(headers): | |
| temp[name] = a[i][j] | |
| result.append(temp) | |
| for i in range(len(result)): | |
| print result[i]['id'],result[i]['name'],result[i]['age'],result[i]['dept'] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment