annotate getcolumnnames.py @ 0:e77c9484b2d0 draft default tip

Uploaded
author saskia-hiltemann
date Thu, 22 Oct 2015 09:18:30 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
1 import os, sys
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
2 import fnmatch
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
3 import csv
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
4
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
5 def get_headers(inputfile):
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
6 columnList=[]
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
7 #line=inputfile.readlines()[0]
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
8 filename=inputfile.get_file_name()
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
9 try:
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
10 f = open(filename)
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
11 line=f.readline()
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
12 while(line[0]=='#' or (not line.strip())): #remove header (starting with hash sign and empty lines to get to headerline
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
13 line=f.readline()
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
14 line = line.strip()
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
15 i=1;
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
16 for col in line.split("\t"):
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
17 label=str(i)+': '+str(col)
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
18 columnList.append([label,label,False])
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
19 i+=1
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
20
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
21 except IOError as e:
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
22 pass
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
23
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
24 return columnList
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
25
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
26
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
27
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
28
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
29
e77c9484b2d0 Uploaded
saskia-hiltemann
parents:
diff changeset
30