Python Forum
How to compressing and decompressing a list to a .csv file? Python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to compressing and decompressing a list to a .csv file? Python
#1
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:

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.close
If anyone can help please let me know, Thanks.
Reply


Messages In This Thread
How to compressing and decompressing a list to a .csv file? Python - by n4meless - Dec-29-2016, 03:17 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020