Created
January 4, 2019 11:12
-
-
Save laibamehnaz/2df0352b0366fdc465942379ebc66608 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gzip | |
import sys | |
import logging | |
print("BEGIN NOTEBOOK") | |
print("OPENING GZIP FILE") | |
#sys.stdout.write() | |
with gzip.open ('/mnt/data/rajiv/AmazonProductReviewDataset/all.txt.gz' , 'rt') as f: | |
file_content = f.read() | |
print("FILE READ") | |
## LIST OF SEPERATED SENTENCES | |
b = str(file_content).split('review/text') | |
texts = " " | |
for i in range(len(b)): | |
if i == 0: | |
continue | |
texts = texts + '\n' + b[i].split('\\n')[0] | |
with open('/home/rajivratn/laiba/AmazonReviews/Amazon_Reviews_Seperated.txt', 'w') as f: | |
f.write(texts) | |
print("FILE WRITTEN") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment