s = ('Monday 7373 3663657 2272 547757699 reached 100%',\ 'Tuesday 7726347 552 766463 2253 under-achieved 0%',\ 'Wednesday 9899898 8488947 6472 77449 reached 100%',\ 'Thursday 636648 553 22344 5699 under-achieved 0%',\ 'Friday 997 3647757 78736632 357599 over-achieved 200%') # Make a table from s table = [line.split() for line in s] # it is possible to transpose the table: transposed = zip(*table) # transposed is now a list each of whose members is a COLUMN of table. ### also OK: zip(*(table)) ## Pick a column col0=transposed[0] ## Find string lengths of each element in col0 col0Lens = [len(str(cell)) for cell in col0] maxwidth_col0 = max(col0Lens) maxWidths = [max([len(str(cell)) for cell in column]) for column in transposed] # format it def formatLine(line): # return [ str.ljust(str(field),w) for (field, w) in zip(line, maxWidths)] return [ str(field).ljust(w) for (field, w) in zip(line, maxWidths)] line0 = formatLine(table[0]) formatted_line0 = '|'.join(line0) NewList = ['|'.join(formatLine(line)) for line in table] # it can be made for all of the lines Str3 = '\n'.join(NewList) # and can be printed in this form print Str3 # Get files in cur dir matching pattern import os, fnmatch fnmatch.filter(os.listdir(os.getcwd()),'*.txt') # ['editors.txt', 'justification_demo.txt', 'python_pitfalls_site.txt', \ # 'rock_paper_scissors.txt', 'Tutor Digest, Vol 29, Issue 32.txt', \ # 'zip_demo.txt'] s = "spam;egg mail" x_re = re.compile(r'[; ]') """ Try this now: >>> s.split("; ") ['spam;egg mail'] >>> x_re.split(s) ['spam', 'egg', 'mail'] >>>