converting char to list in R
Question: I wrote a python script for reading mails' content and append to list and
calling this python script in R. The problem is R is considering the list as
one instead of two elements in it.

Here is my python script:

    
    
    {
    import sys
    import string
    import glob
    
    def parseOutText(f):
        f.seek(0)
        all_text = f.read()
        ### split off metadata
        content = all_text.split("Bcc:")
        return content
    
    def main():
        path = "D:/Hadoop/practice/machine_learning/mails/*.txt"
        files = glob.glob(path)
        file_list = []
        for each_file in files:
            ff = open(each_file, "r")
            text = parseOutText(ff)
            #text = sys.stdout.write(ff.read())
            file_list.append(text)
            ff.close()
        print(file_list)
        print(len(file_list))
    }
    

and the output for this.

> [['From: xxx@xxx.com\nTo: xyz@xxx.com\nSubject: Hi\nCc: abc@xxx.com\nMime-
> Version: 1.0\nContent-Transfer-Encoding: 7bit\n', '
> test@xxx.com\n\nHi,\n\nYour problem is resolved. \n\nPlease reply to this
> email and let us know if it is not working.\n\nThank you \nCCD.'], ['From:
> abc@xxx.com\nTo: test2@xxx.com\nSubject: Hi\nCc: xyz@xxx.com\nMime-Version:
> 1.0\nContent-Transfer-Encoding: 7bit\n', ' test@xxx.com\n\nHi,\n\nThis will
> not work out unless and until you work harder.\n\nThank you \nCCD.']] 2

R code:

    
    
    #setting the working directory to the mails folder
    setwd("D:/Hadoop/practice/machine_learning/mails")
    command = "python"
    output = as.list(system2(command, args = "D:/Hadoop/practice/machine_learning/mails/testR.py", stdout = TRUE))
    print(output)
    print(length(output))
    print(str(output))
    str(command)
    

R output:

> [[1]] [1] "[['From: xxx@xxx.com\nTo: xyz@xxx.com\nSubject: Hi\nCc:
> abc@xxx.com\nMime-Version: 1.0\nContent-Transfer-Encoding: 7bit\n', '
> test@xxx.com\n\nHi,\n\nYour problem is resolved. \n\nPlease reply to this
> email and let us know if it is not working.\n\nThank you \nCCD.'], ['From:
> abc@xxx.com\nTo: test2@xxx.com\nSubject: Hi\nCc: xyz@xxx.com\nMime-Version:
> 1.0\nContent-Transfer-Encoding: 7bit\n', ' test@xxx.com\n\nHi,\n\nThis will
> not work out unless and until you work harder.\n\nThank you \nCCD.']]"
>
> print(length(output)) [1] 1

How can I get two mails as two elements in the same list?

mails:

    
    
    From: xxx@xxx.com
    To: xyz@xxx.com
    Subject: Hi
    Cc: abc@xxx.com
    Mime-Version: 1.0
    Content-Transfer-Encoding: 7bit
    Bcc: test@xxx.com
    
    Hi,
    
    Your problem is resolved. 
    
    Please reply to this email and let us know if it is not working.
    
    Thank you 
    CCD.
    

2nd mail:

    
    
    From: abc@xxx.com
    To: test2@xxx.com
    Subject: Hi
    Cc: xyz@xxx.com
    Mime-Version: 1.0
    Content-Transfer-Encoding: 7bit
    Bcc: test@xxx.com
    
    Hi,
    
    This will not work out unless and until you work harder.
    
    Thank you 
    CCD.
    


Answer: 
    l = as.list(cbind(text1, text2))
    

Gives me the following output:

    
    
    [[1]]
    [1] " From: xxx@xxx.com\nTo: xyz@xxx.com\nSubject: Hi\nCc: abc@xxx.com\nMime-Version: 1.0\nContent-Transfer-Encoding: 7bit\nBcc: test@xxx.com\n\nHi,\n\nYour problem is resolved. \n\nPlease reply to this email and let us know if it is not working.\n\nThank you \nCCD."
    
    [[2]]
    [1] "From: abc@xxx.com\nTo: test2@xxx.com\nSubject: Hi\nCc: xyz@xxx.com\nMime-Version: 1.0\nContent-Transfer-Encoding: 7bit\nBcc: test@xxx.com\n\nHi,\n\nThis will not work out unless and until you work harder.\n\nThank you \nCCD."
    

