Dec-29-2016, 03:17 PM
Hello I was wondering if anyone can help me with this task, I've made an attempt but unsure how to complete, How would i go about compressing and decompressing a list to a .csv file? , see task below, Thanks
Develop a program that builds upon the technique from Task 2 to compress a text file with several sentences, including punctuation. The program should be able to compress a file into a list of words and list of positions to recreate the original file. It should also be able to take a compressed file and recreate the full text, including punctuation and capitalisation, of the original file.
Analyse the requirements for this system and design, develop, test and evaluate a program to compress a text file and reproduce the original text from a compressed file. You will need to create a text file with more than one sentence to test your system.
Code Below:
Develop a program that builds upon the technique from Task 2 to compress a text file with several sentences, including punctuation. The program should be able to compress a file into a list of words and list of positions to recreate the original file. It should also be able to take a compressed file and recreate the full text, including punctuation and capitalisation, of the original file.
Analyse the requirements for this system and design, develop, test and evaluate a program to compress a text file and reproduce the original text from a compressed file. You will need to create a text file with more than one sentence to test your system.
Code Below:
import csv alist = [] blist = [] clist = [] print("Welcome To This Program!") word= input("enter sentence: ") alist=word.split(" ") for i in alist: if i not in blist: blist.append(i) clist.append(blist.index(i)) print(blist) print("\n Positions: ") print(clist) fname = input("Please Enter File Name and Extension: ") file=open(fname, 'w') file.write(','.join(blist)+'\n'+','.join(str(i) for i in clist)) file.closeIf anyone can help please let me know, Thanks.