M
Mike P
Hi All
i have a CSV file that i'm reading in and each line has the look of
the below
{None: ['User-ID', 'Count']}
{None: ['576460847178667334', '1']}
{None: ['576460847178632334', '8']}
i want to make a dictionary of items in the form
{576460847178667334:1, 576460847178632334:8, ..... } for all rows in
the datafile
my code so far is thus:
dict1={}
j=1
for row in reader1:
if j==1:
j+=1
continue #thus allowing me to skip the first row
if j>1:
for element in row.values():
for item in element:
if int(item)%2==0:
dict1[int(item)] = int(item)+1
# i know this is the problem line as it's not picking the second item
up just finding the first and increasing it, but i can't figure out
how to correct this?
j+=1
I get one dictionary from this but not the correct data inside, can
anyone help?
i have a CSV file that i'm reading in and each line has the look of
the below
{None: ['User-ID', 'Count']}
{None: ['576460847178667334', '1']}
{None: ['576460847178632334', '8']}
i want to make a dictionary of items in the form
{576460847178667334:1, 576460847178632334:8, ..... } for all rows in
the datafile
my code so far is thus:
dict1={}
j=1
for row in reader1:
if j==1:
j+=1
continue #thus allowing me to skip the first row
if j>1:
for element in row.values():
for item in element:
if int(item)%2==0:
dict1[int(item)] = int(item)+1
# i know this is the problem line as it's not picking the second item
up just finding the first and increasing it, but i can't figure out
how to correct this?
j+=1
I get one dictionary from this but not the correct data inside, can
anyone help?