Mercurial > repos > saskia-hiltemann > file_manipulation
diff getcolumnnames.py @ 0:e77c9484b2d0 draft default tip
Uploaded
author | saskia-hiltemann |
---|---|
date | Thu, 22 Oct 2015 09:18:30 -0400 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/getcolumnnames.py Thu Oct 22 09:18:30 2015 -0400 @@ -0,0 +1,30 @@ +import os, sys +import fnmatch +import csv + +def get_headers(inputfile): + columnList=[] + #line=inputfile.readlines()[0] + filename=inputfile.get_file_name() + try: + f = open(filename) + line=f.readline() + while(line[0]=='#' or (not line.strip())): #remove header (starting with hash sign and empty lines to get to headerline + line=f.readline() + line = line.strip() + i=1; + for col in line.split("\t"): + label=str(i)+': '+str(col) + columnList.append([label,label,False]) + i+=1 + + except IOError as e: + pass + + return columnList + + + + + +