import sys
from prettytable import from_csv

# This file uses a third party library. PrettyTable: Display data in tables using a beautiful ASCII format.
# Thank you luke@maurits.id.au (code.google.com) for providing the prettytable library.

# TODO: Add sort functionality (ex. sort by URL or genre by alphabetical order)

print "Run 'addCollection' to append Collection(s) to the Collections CSV file.\n"
print "Displaying Collections... This may take awhile.\n"

collectionsData = open("Collections.csv", "r")
collectionsTable = from_csv(collectionsData)
print collectionsTable
collectionsData.close()
x = raw_input("Press enter to exit.")
sys.exit("Completed.")

@@ -341,16 +341,19 @@
 llection
+.py
 ' to app
@@ -406,182 +406,641 @@
 %5Cn%22%0A
-print %22Displaying Collections... This may take awhile.%5Cn%22%0A%0AcollectionsData = open(%22Collections.csv%22, %22r%22)%0AcollectionsTable = from_csv(collectionsData)%0Aprint collectionsTable%0A
+%0AcollectionsData = open(%22Collections.csv%22, %22r%22)%0AcollectionsTable = from_csv(collectionsData)%0A%0A%0Adef displayUnsorted():%0A  print collectionsTable%0A  collectionsData.close()%0A  x = raw_input(%22Press enter to exit.%22)%0A  sys.exit(%22Completed.%22)%0A%0A%0Adef displaySorted():%0A  print %221. Sort by URL%22%0A  print %222. Sort by Genre%22%0A  print %223. Sort by Description%22%0A  sortBy = raw_input(%22Select what you would like to sort by.%22)%0A  if sortBy == %221%22:%0A    print collectionsTable.get_string(sortby='URL')%0A  if sortBy == %222%22:%0A    print collectionsTable.get_string(sortby='Genre')%0A  if sortBy == %223%22:%0A    print collectionsTable.get_string(sortby='Description')%0A  
 coll
@@ -1059,16 +1059,18 @@
 close()%0A
+  
 x = raw_
@@ -1099,16 +1099,18 @@
 exit.%22)%0A
+  
 sys.exit
@@ -1104,28 +1104,386 @@
 %22)%0A  sys.exit(%22Completed.%22)%0A
+%0A%0AsortQ = raw_input(%22Would you like to sort? (Yy/Nn)%22)%0A%0Aif sortQ == %22Y%22 or sortQ == %22y%22:%0A  displaySorted()%0Aelif sortQ == %22N%22 or sortQ == %22n%22:%0A  print %22Displaying unsorted Collection... This may take awhile.%5Cn%22%0A  displayUnsorted()%0Aelse:%0A  print %22I'll take that as a no.%22%0A  print %22Displaying unsorted Collection... This may take awhile.%5Cn%22%0A  displayUnsorted()%0A

Add sorting functionality