last day (14 days later) » 

2:37 PM
1
A: Hierarchical JSON from csv python

C PandaThe following snippet finds all the node of a tree without actually creating one. Tree and linked list implementation in Python is inefficient (Beazley). from itertools import groupby import csv with open('csvfile.csv') as f: reader = csv.DictReader(f) groups = groupby(reader, key=lambda r...

 
@miltonjbradley which lines bdw?
 
I like the clean code. However, it does not make the tree structure explicit.
 
@schwobaseggl I am aware of that. As I don't know how the heirarchy looks like. I can't give any semantics to the result dict keys. My python tree will always be a dict. But i want to know how it looks like.
 
@CPanda I think it will be cleaner if you remove the redundant code from the inner dicts, and just use name:count key-value pairs. That would make the result it much less verbose without losing information.
 
@schwobaseggl That's not redundant "code". That's unwanted "output" which tallies the original input before making name: count transformation.
 
2:37 PM
@CPanda Hmm.. maybe a misunderstanding of code ;) I meant the 'code' keys in your output that were redundant. d = {i: {x['Name']: x['count'] for x in g} for i, g in gs} would produce what I spoke of.
 
@schwobaseggl Understood. My mistake.
@schwobaseggl edited it.
 
@CPanda We are so gonna get that Sportsmanship badge, lol
 
what badge??!!
@schwobaseggl what badge!!
@schwobaseggl let me check what you are referring to.
@schwobaseggl what sportmanship badge. i didn't see any..there is a tenacious badge.
@schwobaseggl i got that probably because i posted some answers that nobody wanted.
 
@CPanda it is a silver badge for upvoting answers to questions where you have posted answer yourself :)
 
2:55 PM
@schwobaseggl i see...bdw my graph was kinda flat for some time(a week at least). I am started again.
 

last day (14 days later) »