From d6f92c7c7d376659c6616f58be7b6173fca761e5 Mon Sep 17 00:00:00 2001 From: Aliaksandr Spichakou Date: Tue, 12 Mar 2019 22:43:09 +0300 Subject: [PATCH] Add missed file --- code/src/file_reader.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 code/src/file_reader.py diff --git a/code/src/file_reader.py b/code/src/file_reader.py new file mode 100644 index 0000000..36ae5da --- /dev/null +++ b/code/src/file_reader.py @@ -0,0 +1,22 @@ +from abc import abstractmethod +import pandas as pd +from bs4 import BeautifulSoup + +class FileReader(): + def __init__(self): + pass + + @abstractmethod + def annotate(self, text): + f = open(text,'r') + return f.read() + + def make_dict(self, list_of_inside_tag_strings, fucntion): + dictionary = {string: fucntion(string) for string in list_of_inside_tag_strings} + return dictionary + + def read_csv(self, path, sep): + return pd.read_csv(path, index_col=None, sep=sep) + + def read_xml(self, text): + return BeautifulSoup(''+text+'', "lxml")