title: I want to check if a value in csv exist in another csv file return 1
body: <p>I have 2 csv files: one is <code>dictionary.csv</code> and the other one is <code>file.csv</code>, which contains a lots of words. I wanted to check if a word in <code>dictionary.csv</code> exists in a specific column of <code>file.csv</code>. </p>
  
  <p>If it exists, a new file <code>new.csv</code>should be created. That file should  contain all data from file.csv but with one extra column that writes 1 if it exists and 0 if it does not exist.</p>
  
  <p>These is the script I have:</p>
  
  <pre><code>import csv
  import pandas as pd
  
  news=pd.read_csv("file.csv")
  
  dictionary=pd.read_csv("dictionary.csv", squeeze=True)
  
  pattern = '|'.join(dictionary)
  
  exist=news['sentences'].str.contains(pattern, na=False)
  
  with open('new.csv', 'w') as outFile:
      for cols in exist:
          if pattern in exist:
              outFile.write(exist, "1")
  </code></pre>
  
  <p>As a result, I get an empty csv file, I guess I might have missed something.</p>
  
  <pre><code>file.csv
  id      sentences
  0        Roses are red
  1        burgers are delicious
  </code></pre>
  
  <pre><code>dictionary.csv
  red
  blue
  green
  </code></pre>
  
  <p>The <code>new.csv</code> file should contain the following output:</p>
  
  <pre><code>id      sentences                exist/not exist
  0        Roses are red               1
  1        burgers are delicious       0
  </code></pre>