import pandas as pd
import os 


indir = '/shared/soniat/misc/basespace_FT/mount/Projects/MiSeq M02127 2016 Run206/AppResults/'

dfs={}


for samp_id, bcnum in dict(zip(['UC-23 B','UC-23 A','UC-22 C'], [73,85,97])).items():
    infile = '{}/{} (2)/Files/{}_S{}.summary.csv'.format(indir, samp_id, samp_id.replace(' ','-'), bcnum)
    dfs[samp_id] = pd.read_table(infile, sep=',')
    dfs[samp_id].set_index( list(dfs[samp_id].columns[:-2]) , inplace=True)
    dfs[samp_id].drop( "%_hits", axis=1, inplace=True)


all = pd.concat(dfs, axis=1)


for samp_id in ['UC-23 B','UC-23 A','UC-22 C']:
    relevant_path = '{}/{} (2)/Files/'.format(indir,samp_id)
    included_extenstions = ['csv']
    file_names = [fn for fn in os.listdir(relevant_path)
                  if  (fn.startswith(samp_id.replace(' ','-'))
                  and fn.endswith('csv')) ]
    print(file_names)
    assert (len(file_names)==1)
    infile = file_names[0]



@@ -1,12 +1,45 @@
+__author__ = %22Sonia Timberlake%22%0A%0A
 import panda
@@ -163,17 +163,421 @@
 dfs=%7B%7D%0A%0A
-%0A
+def parse_SampleSheet(sampsheetfile):%0A    ''' rudimentary Miseq SampleSheet.csv --%3E df parser ''' %0A    with open(sampesheetfile,'r') as f: lines=readlines()%0A    start_line = %5Bi for i in range(len(lines)) if 'Data' in lines%5Bi%5D %5D%0A    table = %5Bline.strip().split(',') for line in lines%5B1+start_lines:%5D%5D%0A    df = pd.DataFrame( data=table%5B1:%5D, columns = table%5B0%5D)%0A    return df %0A            %0A%0Adef __old():%0A    
 for samp
@@ -650,24 +650,28 @@
 )).items():%0A
+    
     infile =
@@ -764,24 +764,28 @@
  bcnum)%0A    
+  
+  
 dfs%5Bsamp_id%5D
@@ -818,16 +818,20 @@
 ep=',')%0A
+    
     dfs%5B
@@ -898,16 +898,20 @@
 e=True)%0A
+    
     dfs%5B
@@ -959,16 +959,20 @@
 True)%0A%0A%0A
+    
 all = pd
@@ -997,24 +997,40 @@
 1)%0A%0A
-%0Afor 
+def read_three_samples(
 samp_id
- in 
+s=
 %5B'UC
@@ -1056,18 +1056,52 @@
 C-22 C'%5D
+)
 :%0A
+    for samp_id in samp_ids:%0A    
     rele
@@ -1157,16 +1157,20 @@
 id)%0A    
+  
+  
 included
@@ -1192,16 +1192,20 @@
 %5B'csv'%5D%0A
+    
     file
@@ -1271,16 +1271,20 @@
         
+    
 if  (fn.
@@ -1338,16 +1338,20 @@
         
+ 
+   
 and fn.e
@@ -1372,16 +1372,20 @@
 ) %5D%0A    
+   
+ 
 print(fi
@@ -1394,16 +1394,20 @@
 _names)%0A
+    
     asse
@@ -1430,24 +1430,28 @@
 es)==1)%0A    
+ 
+   
 infile = fil
@@ -1461,10 +1461,949 @@
 ames%5B0%5D%0A
-%0A
+        dfs%5Bsamp_id%5D = pd.read_table(infile, sep=',')%0A        dfs%5Bsamp_id%5D.set_index( list(dfs%5Bsamp_id%5D.columns%5B:-2%5D) , inplace=True)%0A        dfs%5Bsamp_id%5D.drop( %22%25_hits%22, axis=1, inplace=True)%0A%0A    all = pd.concat(dfs, axis=1)%0A    return all%0A%0Adef parse_args(argv):%0A    parser = argparse.ArgumentParser(usage=__doc__,%0A                                     description='''%0A                                     get sample info from Sample Sheet,%0A                                     join csvs from basespace App dir %0A                                     ''')%0A    parser.add_argument('--in-clone-stats', %0A                        type=argparse.FileType('r'), default=sys.stdin)%0A    parser.add_argument('--in-premode',%0A                        type=argparse.FileType('r')%0A%0A%0Adef main(argv=None):%0A    if not argv == 0: sys.exit()%0A    opts = parse_args(argv)%0A    df = parse_SampleSheet(sampsheetfile)%0A%0Aif __name__ == '__main__':%0A    main(sys.argv%5B1:%5D)
 %0A

add proper skeleton