I write a lot of Perl/Python scripts and know a bit of C++ but I would like to learn more.
How do I do the following in C++
#!/usr/env python
# dict of lists
d = {}
d[0]=[]
d[0].append('Group1')
d[0].append('Group2')
d[1]=[]
d[1].append('GroupA')
d[1].append('GroupB')
# split a string delimited by tabs
# increment dict values
d ={}
with open(fh) as f:
for l in f:
r = l.rstrip('\n').split('\t')
# r[0] can be Group1, Group2, GroupA, Group B
if d.get(r[0]) == None: d[r[0]]=1
else: d[r[0]]+=1
# iterate through the dict
for x in d:
print x,d[x]
Thanks :)
I'm writing a genetics tool that you can use with your 23andMe/Ancestry data so if you guys help me I will eventually put up the code with the subject "Ancestry Analysis C++ Thanks /g/"