Aug-02-2018, 09:39 PM
I am having trouble dealing with long strings in python. Specifically, I would like to append them to an array. However, whenever I do so and print the array, the output I get is merely the following:
[[...]]
I get the same thing in a CSV file when I try to export it, suggesting that it is not just a display error. Could someone please take a look at my code below and suggest how I can store long-form text in an array. Although the example below is just for one corpus, I will need to store multiple text corpuses in one data structure.
---
[[...]]
I get the same thing in a CSV file when I try to export it, suggesting that it is not just a display error. Could someone please take a look at my code below and suggest how I can store long-form text in an array. Although the example below is just for one corpus, I will need to store multiple text corpuses in one data structure.
---
from __future__ import print_function import urllib2 import xml.etree.ElementTree as ET site = "http://video.google.com/timedtext?lang=en&v=" videoID = "PSad5j8w-Ls" response = urllib2.urlopen(site+videoID) xml = ET.fromstring(response.read()) captions = [] content = ' '.join([i.text.replace("'", "'").replace(""", '"') for i in xml]) captions.append(captions) print(captions[0])