Python Forum
Trouble adding LONG strings to an array or CSV output
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trouble adding LONG strings to an array or CSV output
#1
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.

---
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])
Reply
#2
You are appending an empty list to itself
captions.append(captions)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Trying to understand strings and lists of strings Konstantin23 2 777 Aug-06-2023, 11:42 AM
Last Post: deanhystad
  Splitting strings in list of strings jesse68 3 1,780 Mar-02-2022, 05:15 PM
Last Post: DeaD_EyE
  print function output wrong with strings. mposwal 5 3,139 Feb-12-2021, 09:04 AM
Last Post: DPaul
  trouble with list array Milfredo 2 2,048 Sep-16-2020, 12:07 AM
Last Post: Milfredo
  Split a long string into other strings with no delimiters/characters krewlaz 4 2,803 Nov-15-2019, 02:48 PM
Last Post: ichabod801
  Adding markers to Folium map only adding last element. tantony 0 2,133 Oct-16-2019, 03:28 PM
Last Post: tantony
  Finding multiple strings between the two same strings Slither 1 2,531 Jun-05-2019, 09:02 PM
Last Post: Yoriz
  For loop (adding strings to a list trouble) eoins 2 3,046 Jul-03-2018, 10:36 AM
Last Post: volcano63
  lists, strings, and byte strings Skaperen 2 4,243 Mar-02-2018, 02:12 AM
Last Post: Skaperen
  How to make an input trigger the output once no matter how long input is high cam2363 3 3,266 Feb-05-2018, 01:19 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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