title: Dividing a string into 3 parts and export to CSV in JAVA
body: <p>I have a string &quot;<strong>1 kg potatoes</strong>&quot; whereas <strong>1</strong> is the quantity, <strong>kg</strong> is the unit and <strong>potatoes</strong> is the item. I want that the compiler will read a string and match with &quot;unit_list  &amp; quantity_list&quot;(see code below). And it saves the results into 3 columns in a CSV file.</p>
  <pre><code>   List&lt;String&gt; unit_list = Arrays.asList(&quot;g&quot;, &quot;kg&quot;,&quot;ml&quot;,&quot;l&quot;);          
     List&lt;String&gt; quantity_list = Arrays.asList(&quot;Full&quot;, &quot;Quarter&quot;, &quot;Half&quot;, &quot;3 Quarter&quot;, &quot;1&quot;, &quot;2&quot;, &quot;3&quot;, &quot;4&quot;, &quot;5&quot;, &quot;6&quot;, &quot;7&quot;, &quot;8&quot;, &quot;9&quot;, &quot;0&quot;);                                                                                                   
                                                                                                                                                                                                                                                                 
     String input = &quot;1 kg potatoes&quot;;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
                                                                                                                                                                              
     if (unit_list.equals(input)) {                                                                                                                                                                                                               
         System.out.println(&quot;Unit Detected&quot;);                                                                                                                                                                                                                    
     }  
                                                                                                                                                                                                                                                           
     if (quantity_list.equals(input)) {                                                                                                                                                                                                    
         System.out.println(&quot;Quantity Detected&quot;);                                                                                                                                                                                                                
     }                                                                                                                                                                                                                                                           
  </code></pre>
  <blockquote>
  <p>Expected Output in CSV File</p>
  <p><strong>Quantity, Unit, Item</strong></p>
  <p>1, kg , potatoes</p>
  </blockquote>
  <p>But this is not working for me. Please help me to do this.</p>