Title / Description
Code #!/opt/local/bin/python # -*- coding: utf-8 -*- import os import math import csv import sys # Lire le fichier de ranges... with open(sys.argv[1], "rb") as infile, open("IRanges.txt", "wb") as outfile: reader = csv.reader(infile) writer = csv.writer(outfile, quoting=False) writer.writerow(["Start\tEnd\tLength"]) #Initialize variables IRval_s=0 IRval_e=0 idx=0 lgth=0 for i, line in enumerate(reader): print "Processing line " + str(i) + " : " + ''.join(line) + "\n" # skip first line corresponding to comments if i < 1: continue #if i > 20: break IRrange = line[0].split() # traitement des lignes paires (le +1 est parce qu'on a skippé la premiere ligne) if (i+1) % 2 == 0: IRval_s=int(IRrange[1])+1 else: IRval_e=int(IRrange[0])-1 lgth=IRval_e - IRval_s + 1 newline=str(IRval_s) + "\t" + str(IRval_e) + "\t" + str(lgth) print "Ici c'est: " + newline writer.writerow([newline]) #Reset variables IRval_s=0 IRval_e=0 lgth=0 infile.close() outfile.close()
Author
Highlight as C C++ CSS Clojure Delphi ERb Groovy (beta) HAML HTML JSON Java JavaScript PHP Plain text Python Ruby SQL XML YAML diff code