1

I have some text to convert from excel to xml adding the objects “Scope” and “Cue” to some parts of that text.

When object “Cue” is present, object “Scope” must be present. However, they are not nested: they can be in different parts of the text (in other words, “Scope” is not within “Cue” or viceversa). Both objects are created by the functions mark_scope(value) and mark_cue(value) which work fine. I am using ElementTree to build objects.

I am able to create an xml file that has either text marked as “Scope” or “Cue”, but not both, which is what I need. 

I tried to use “and” to pass text first through mark_scope and then through mark_cue but I get the following error:

FutureWarning: The behavior of this method will change in future versions. Use specific 'len(elem)' or 'elem is not None' test instead. element = make_text(value) and make_cue(value)

Here is the section of my program that doesn't work (I don't want to post the whole program now because it's too long, but I'll be happy to do so if you need that information).

for row in excel_data:
    tweet = ET.Element("Tweet") 
    for key in row:
        value = row[key]
        element = None
        if key is 'Text':
            element = make_text(value) and make_cue(value)
        else:
            element = ET.Element(key)
            element.text = unicode(value)

        tweet.append(element)
    corpus.append(tweet)
Praveen
  • 6,872
  • 3
  • 43
  • 62
norpa
  • 127
  • 2
  • 16
  • What do the functions `make_text` and `make_cue` do? Also note that `x and y` returns `x` if it evaluates to `False` and `y` otherwise. – a_guest Oct 03 '17 at 19:27

0 Answers0