<commit_before>#!/usr/bin/python
"""Export all responses from yesterday and save them to a .csv file."""

import sqlite3
import csv
from datetime import datetime, timedelta
import os
import time


today = str(datetime.now().strftime('%Y-%m-%d'))
yesterday = str((datetime.now() - timedelta(days=1)).strftime('%Y-%m-%d'))

today_timestamp = datetime.now().timestamp() #returns the dateime as a timestamp
yesterday_timestamp = (datetime.now() - timedelta(days = 1)).timestamp()

## SQLITE3 VARIABLES
sqlite_query = 'SELECT * FROM responses WHERE unixTime BETWEEN ' + str(yesterday_timestamp) + ' AND ' + str(today_timestamp) + ' '


export_directory = '../archive'
export_filename = yesterday + '_responses' + '.csv'
full_export_path = os.path.join(export_directory, export_filename)

sqlite_file = '../archive/srvy.db'
table_name = 'responses'


conn =  sqlite3.connect(sqlite_file)
c = conn.cursor()

try:
    c.execute(sqlite_query)
    csvWriter = csv.writer(open(full_export_path, 'w'))
    rows = c.fetchall()

    for row in rows:
        csvWriter.writerow(row)
except:
    pass<commit_msg>Don't export unixTime column Unnecessary to view Unix time in Excel spreadsheet<commit_after>#!/usr/bin/python
"""Export all responses from yesterday and save them to a .csv file."""

import sqlite3
import csv
from datetime import datetime, timedelta
import os
import time


today = str(datetime.now().strftime('%Y-%m-%d'))
yesterday = str((datetime.now() - timedelta(days=1)).strftime('%Y-%m-%d'))

today_timestamp = datetime.now().timestamp() #returns the dateime as a timestamp
yesterday_timestamp = (datetime.now() - timedelta(days = 1)).timestamp()

## SQLITE3 VARIABLES
sqlite_query = 'SELECT response_key, pythonDateTime, question, opinion FROM responses WHERE unixTime BETWEEN ' + str(yesterday_timestamp) + ' AND ' + str(today_timestamp) + ' '


export_directory = '../archive'
export_filename = yesterday + '_responses' + '.csv'
full_export_path = os.path.join(export_directory, export_filename)

sqlite_file = '../archive/srvy.db'
table_name = 'responses'


conn =  sqlite3.connect(sqlite_file)
c = conn.cursor()

try:
    c.execute(sqlite_query)
    csvWriter = csv.writer(open(full_export_path, 'w'))
    rows = c.fetchall()

    for row in rows:
        csvWriter.writerow(row)
except:
    pass
{'fraction_non_alphanumeric': 0.13585069444444445, 'fraction_numerical': 0.004340277777777778, 'mean_word_length': 4.776942355889724, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5500837', 'n_tokens_mistral': 781, 'n_tokens_neox': 734, 'n_words': 186}