def read_csv(directory):
if path.isdir(directory):<EOL><INDENT>csvfile = path.join(directory, '<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>csvfile = directory<EOL><DEDENT>with open(csvfile, '<STR_LIT:r>') as f:<EOL><INDENT>for tweet in csv.DictReader(f):<EOL><INDENT>try:<EOL><INDENT>tweet['<STR_LIT:text>'] = tweet['<STR_LIT:text>'].decode('<STR_LIT:utf-8>')<EOL><DEDENT>except AttributeError:<EOL><INDENT>pass<EOL><DEDENT>yield tweet<EOL><DEDENT><DEDENT>
Scrape a twitter archive csv, yielding tweet text.

Args:
    directory (str): CSV file or (directory containing tweets.csv).
    field (str): Field with the tweet's text (default: text).
    fieldnames (list): The column names for a csv with no header. Must contain <field>.
                        Leave as None to read CSV header (default: None).

Returns:
    generator