How to create an rray of composites strings
<p>Hi everyone: I have a collection of 50 strings that represent comments in a text file where each line represents a separate comment with different sentences . </p>

<p>Each string is a user review of a product, and each string or review has several several sentences. </p>

<p>How could I to create an array with these strings using Python?</p>

<p>Example of reviews:
Review 1.  "I was disapointed with the product. The quality was reality bad and the price was not fair.  Never in my life I'll buy again this brand.</p>

<p>Review 2. "I'm really happy with this product.  It's all what i desired.  Thanks brand J"
.... and so far.</p>

<p>Desired Results: </p>

<ol>
<li><p>[('disappointed', 'product'), ('quality', 'really', 'bad', 'price', 'fair')] </p></li>
<li><p>[('happy', 'product'), ('all', 'desired'), ('thanks', 'brand')] </p></li>
<li>... </li>
</ol>

<p>I want each processed comment in a separate line to save it in a csv file</p>

<p>One of my first projects was similar to this. I believe your asking for help in getting the text file lines as an array.</p>

<p>To open the file for reading: </p>

<p><code>file = open("/path/to/file", "r")</code></p>

<p>I would then split on spaces so: </p>

<pre><code>for line in file: 
      print line.split(' ')
</code></pre>

<p>this would give you an array of words from each line in the txt file. 
Then use the <code>csv</code> module in python to input into a csv file. </p>

<p>References: </p>

<ul>
<li><p><a href="http://www.pythonforbeginners.com/files/reading-and-writing-files-in-python" rel="nofollow">Python the Hard Way - Opening and Closting Files</a></p></li>
<li><p><a href="https://www.dotnetperls.com/split-python" rel="nofollow">split() function</a></p></li>
<li><p><a href="http://www.pythonforbeginners.com/systems-programming/using-the-csv-module-in-python/" rel="nofollow">CSV Module</a></p></li>
</ul>

python arrays string