On 04.06.2014 12:29, jarod...@libero.it wrote:
Dear all thanks for your suggestion!!!
In [4]: with open("prova.csv") as p:
for i in p:
lines =i.rstrip("\n").split("\t")
line = (lines[0],lines[1])
...: diz.setdefault(line,set()).add(lines[2])
...:
In [5]: d
jarod...@libero.it wrote:
> Dear all thanks for your suggestion!!!
> Thanks to your suggestion I create this structure:with open("prova.csv")
> as p:
> for i in p:
> lines =i.rstrip("\n").split("\t")
>...: print lines
>...:
> ['programs ', 'sample', 'gene', 'values']
>
Hi,
I'd suggest using different data structure for the intersect of samples
from a program.
data = {
'program1':
{
'sample1': {'TP53', 'ASD'},
'sample2': {'ASD'},
},
'program2': {
'sample1': {'ASD'}
}
}
this way you can do this:
for program in data:
pr
Dear all thanks for your suggestion!!!
Thanks to your suggestion I create this structure:with open("prova.csv") as p:
for i in p:
lines =i.rstrip("\n").split("\t")
...: print lines
...:
['programs ', 'sample', 'gene', 'values']
['program1', 'sample1', 'TP53', '2']
On 03.06.2014 21:56, Wolfgang Maier wrote:
- the tricky part is what to do with keys that are encountered for the
first time and, thus, don't have a set associated with them yet.
Here, dict.setdefault() will help you
(https://docs.python.org/2.7/library/stdtypes.html?highlight=setdefault#dict.se
On 03/06/2014 17:24, jarod...@libero.it wrote:
HI there!!!
I have afile like this:
file.txt
programssample gene
program1sample1 TP53
program1sample1 TP53
program1sample2 PRNP
program1sample2 ATF3
program2sample1 TP53
program2sample1 PRNP
p
On 03.06.2014 18:24, jarod...@libero.it wrote:
HI there!!!
I have afile like this:
file.txt
programssample gene
program1sample1 TP53
program1sample1 TP53
program1sample2 PRNP
program1sample2 ATF3
program2sample1 TP53
program2sample1 PRNP
p
On 03/06/14 17:24, jarod...@libero.it wrote:
with open("prova.csv") as p:
If processing csv files its usually better to use the csv modulew, it
can handle many obscure quoting issues etc, especially if the data is
sourced from, say, Excel.
In particular I recommend using the dict-reader wh
HI there!!!
I have afile like this:
file.txt
programssample gene
program1sample1 TP53
program1sample1 TP53
program1sample2 PRNP
program1sample2 ATF3
program2sample1 TP53
program2sample1 PRNP
program2sample2 TRIM32
program2sam