Socialify

Folder ..

Viewing database_handler.py
14 lines (11 loc) • 313.0 B

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
import pandas as pd


class DatabaseHandler:

    def write(self, df):
        # save the data to csv
        df.to_csv('reddit.csv', index=False)

    def read(self):
        try:
            df = pd.read_csv('reddit.csv')
            return df
        except FileNotFoundError:
            return pd.DataFrame()