[Tutor] Problem on filtering data

Alan Gauld alan.gauld at btinternet.com
Mon Jun 8 17:52:04 CEST 2015


On 08/06/15 15:50, jarod_v6--- via Tutor wrote:

> with open("Dati_differenzialigistvsminigist_solodiff.csv") as p:

You are usually better off processing CSV files (or in your case tab 
separated) using the CSV module.

>      for i in p:
>          lines = i.strip("\n").split("\t")
>          if lines[8] != "NA":
>              if lines[8] :
>                  print lines[8]
>
> Why I continue to obtain "" empity line?

What does empty line mean?
Do you get a line printed with no content?
Or no line printed?

I've no idea, but I do notice that you last line is not complete
  - ie it only has 8 fields. so lines[8] != "NA" should fail with an 
index error!

Also your headings only have 10 entries but your lines have 11?
Also you are processing the headings line in the same way as the rest of 
the data, is that correct?

>
> "baseMean"    "log2FoldChange"    "lfcSE"    "stat"    "pvalue"    "padj"    "ensembl"    "hgnc_symbol"    "uniprot"    "entrez"
> "ENSG00000001460"    49.2127074325806    -1.23024931383259    0.386060601796602    -3.18667408201565    0.00143918849913772    0.0214436050108864    "ENSG00000001460"    "STPG1"    "Q5TH74"    90529
> "ENSG00000004779"    110.066557414377    1.0371628629106    0.375665509210244    2.76086794630418    0.00576479803838396    0.0552052693506261    "ENSG0

HTH

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list