Esempio n. 1
0
 def test_squareRoot(self):
     test_data = CsvReader("Tests/Data/Unit Test Square Root.csv").data
     for row in test_data:
         res = float(row['Result'])
         self.assertEqual(self.calculator.squareRootRes(row['Value 1']),
                          round(res, 8))
         self.assertEqual(self.calculator.res, round(res, 8))
Esempio n. 2
0
 def test_subtraction(self):
     test_data = CsvReader("Tests/Data/Unit Test Subtraction.csv").data
     for row in test_data:
         res = float(row['Result'])
         self.assertEqual(
             self.calculator.subRes(row['Value 2'], row['Value 1']), res)
         self.assertEqual(self.calculator.res, res)
Esempio n. 3
0
 def test_subtract_method_calculator(self):
     self.test_data = CsvReader('src/td/subtraction.csv').data
     for row in self.test_data:
         self.assertEqual(
             self.calculator.subtract(row['Value 1'], row['Value 2']),
             int(row['Result']))
         self.assertEqual(self.calculator.result, int(row['Result']))
Esempio n. 4
0
 def test_sqrtSquared(self):
     test_data = CsvReader(
         "Tests/Data/Unit Test Square Root plus Squared.csv").data
     for row in test_data:
         res = float(row['Result'])
         self.assertEqual(self.calculator.sqrtSquared(row['Value 1']), res)
         self.assertEqual(self.calculator.res, res)
Esempio n. 5
0
 def test_multiply_method_calculator(self):
     self.test_data = CsvReader('src/td/multiplication.csv').data
     for row in self.test_data:
         self.assertEqual(
             self.calculator.multiply(row['Value 1'], row['Value 2']),
             Decimal(row['Result']))
         self.assertEqual(self.calculator.result, int(row['Result']))
Esempio n. 6
0
 def test_divide_method_calculator(self):
     self.test_data = CsvReader('src/td/division.csv').data
     for row in self.test_data:
         self.assertEqual(
             self.calculator.divide(row['Value 1'], row['Value 2']),
             Decimal(row['Result']))
         self.assertEqual(self.calculator.divide('0', row['Value 2']),
                          'error, the divisor can not be zero')
Esempio n. 7
0
 def test_multAdd(self):
     test_data = CsvReader(
         "Tests/Data/Unit Test Multiplication plus Addition.csv").data
     for row in test_data:
         res = float(row['Result'])
         self.assertEqual(
             self.calculator.multAdd(row['Value 1'], row['Value 2'],
                                     row['Value 3'], row['Value 4']), res)
         self.assertEqual(self.calculator.res, res)
Esempio n. 8
0
 def test_addSubDiv(self):
     test_data = CsvReader("Tests/Data/Unit Test Add Sub Div.csv").data
     for row in test_data:
         res = float(row['Result'])
         self.assertEqual(
             self.calculator.addSubDiv(row['Value 1'], row['Value 2'],
                                       row['Value 3'], row['Value 4'],
                                       row['Value 5']), res)
         self.assertEqual(self.calculator.res, res)
Esempio n. 9
0
class MyTestCase(unittest.TestCase):
    def setUp(self) -> None:
        self.csv_reader = CsvReader('src/td/addition.csv')

    def test_return_data_as_objects(self):
        values = self.csv_reader.return_data_as_objects('a_value')
        self.assertIsInstance(values, list)
        test_class = class_factory('a_value', self.csv_reader.data[0])
        for a_value in values:
            self.assertEqual(a_value[0], test_class[0])
Esempio n. 10
0
class MyTestCase(unittest.TestCase):
    def setUp(self) -> None:
        self.csv_reader = CsvReader('Tests/Data/testJobs.csv')

    def test_return_as_objects(self):
        staff = self.csv_reader.return_data_as_class('job')
        self.assertIsInstance(staff, list)
        test_class = ClassFactory('job', self.csv_reader.data[0])

        for job in staff:
            self.assertEqual(job.__name__, test_class.__name__)
Esempio n. 11
0
    def Load(self, shopsPath, tagsPath, taggingsPath, productsPath):
        """ Loads provided csv files into entities/models. Returns a list of ShopLocation objects """

        reader = CsvReader()
        #read files into entity collections
        shops = reader.Read(shopsPath, Extenders.InitializeExtendedShop)
        tags = reader.Read(tagsPath)
        taggings = reader.ReadList(taggingsPath)
        products = reader.ReadList(productsPath)

        #match shops with tags
        for tagging in taggings:
            try:
                #tags are added in lowercase for case insensitive comparison. Lowercase comparison does not work for all cultures, consider using another method
                shops[tagging.shop_id].tags.add(
                    tags[tagging.tag_id].tag.lower())
            except KeyError:
                continue
        #match shops with products
        for product in products:
            try:
                shops[product.shop_id].products.add(product)
            except KeyError:
                continue

        #build a list of ShopLocation objects to represent final results
        shopLocationCollection = []
        for i, shop in shops.iteritems():
            coordinates = CoordinateHelper.CastString2Coordinates(
                shop.lat, shop.lng)

            if (coordinates == None):
                continue
            else:
                shopLocationCollection.append(ShopLocation(shop, coordinates))

        #return a list of ShopLocation objects
        return shopLocationCollection
Esempio n. 12
0
    def parseFile(self):

        for guiLine in self.guiMap:
            ( filename, ibans, combo, checkButton, state ) = guiLine

            if state.get():
                ibanType = combo.get()
                
                config = Config()
                fields = config.getCurrentBank( ibanType )

                bankStatement = BankStatement()

                bankStatement.account = ibans[0]

                csvReader = CsvReader(fields)
            
                csvReader.readFile( filename, bankStatement )

                ofx = Ofx()

                ofx.createXmlFile( filename, bankStatement )
                checkButton.configure(state=constants.DISABLED)
Esempio n. 13
0
 def test_multiply_method_calculator(self):
     test_data = CsvReader("/src/data/Unit Test Multiplication.csv").get_data
     for row in test_data:
         self.assertEqual(self.calculator.multiply(row['Value 1'], row['Value 2']), float(row['Result']))
         self.assertEqual(self.calculator.result, float(row['Result']))
Esempio n. 14
0
 def test_divide_method_calculator(self):
     test_data = CsvReader("/src/data/Unit Test Division.csv").get_data
     for row in test_data:
         self.assertAlmostEqual(self.calculator.divide(row['Value 2'], row['Value 1']), float(row['Result']))
         self.assertAlmostEqual(self.calculator.result, float(row['Result']))
Esempio n. 15
0
from csvReader import CsvReader
from regexChecker import RegexChecker as rc
from textChecker import TextChecker as tc
import re
import pandas as pd

if __name__ == "__main__":
    # pandas display option to show full df
    pd.set_option('display.max_rows', 500)
    pd.set_option('display.max_columns', 500)
    pd.set_option('display.width', 1000)

    # path = "C:\\Users\\Ko.In\\Desktop\\testdata.csv"
    path = "C:\\Users\\Ko.In\\Desktop\\PiiExtractionData\\callcenter_data (201809).csv"
    reader = CsvReader(path)
    filtered_df = CsvReader.filtered_df(reader.df)

    msgs = list(filtered_df["本文[msg.body]"])

    email_regex = rc.email_regex()
    phone_regex = rc.phone_regex()

    result = []
    count = 0
    while count < len(msgs):
        match = False
        row = {}
        email = re.findall(email_regex, msgs[count])
        phone = re.findall(phone_regex, msgs[count])
        if len(email) > 0:
            row["Email"] = email
Esempio n. 16
0
 def test_squareroot_method_calculator(self):
     test_data = CsvReader("/src/data/Unit Test Square Root.csv").get_data
     for row in test_data:
         self.assertAlmostEqual(self.calculator.square_root(row['Value 1']), float(row['Result']))
         self.assertAlmostEqual(self.calculator.result, float(row['Result']))
Esempio n. 17
0
 def setUp(self) -> None:
     self.csv_reader = CsvReader('src/td/addition.csv')
Esempio n. 18
0
from datetime import datetime

from csvReader import CsvReader
from googleFormWriter import GoogleFormWriter

from question import Question
from text import Text

if __name__ == '__main__':
    """ HIER INFOS ANGEBEN """
    # Speicherort der Baum-CSV-Datei
    csv_file = '../data/Baum_Incom.csv'
    # Projekt Titel
    #project_title = "Version_{}".format(datetime.now().strftime("%Y-%m-%d_%H-%M-%S"))
    project_title = "Beratungslotse - Follow Me! (Incom)"
    # Speicherort der gs-Datei.
    gs_file = "../data/Baum_Incom.gs".format(project_title)

    # Lesen der CSV-Datei
    pages_dict = CsvReader.read(csv_file)

    # Schreiben in die gs-Datei
    GoogleFormWriter.write(pages_dict=pages_dict,
                           project_title=project_title,
                           file_name=gs_file)
Esempio n. 19
0
 def test_square_method_calculator(self):
     self.test_data = CsvReader('src/td/square.csv').data
     for row in self.test_data:
         self.assertEqual(self.calculator.square(row['Value 1']),
                          Decimal(row['Result']))
         self.assertEqual(self.calculator.result, int(row['Result']))
Esempio n. 20
0
 def test_square_root_method_calculator(self):
     self.test_data = CsvReader('src/td/squareRoot.csv').data
     for row in self.test_data:
         self.assertEqual(self.calculator.square_root(row['Value 1']),
                          float(row['Result']))
         self.assertEqual(self.calculator.result, float(row['Result']))
Esempio n. 21
0
 def setUp(self) -> None:
     self.csv_reader = CsvReader('Tests/Data/testJobs.csv')
Esempio n. 22
0
from csvReader import CsvReader

columnsNamesToExtract = [
    'director_name', 'actor_2_name', 'actor_1_name', 'actor_3_name', 'gross',
    'genres', 'movie_title', 'num_voted_users', 'imdb_score'
]

csvReader = CsvReader('dataset.csv', 'Movie', columnsNamesToExtract)
csvReader.setChunkSize(5)
csvIterator = iter(csvReader)

for movies in csvIterator:
    for movie in movies:
        print(movie.movie_title)
    print("\n")
Esempio n. 23
0
                #print("inside args tag",args.tag)
                res_list = res.get_ec2_resources_on_taginfo(tagonly=args.tag)
                print(res_list)
        # if the script runs with both tag key and  value
            if (args.tag and args.value):
                #print("inside args tag value",args.tag,args.value)
                res_list = res.get_ec2_resources_on_taginfo(key=args.tag,
                                                            value=args.value)
                print(res_list)
        # if the script runs in batch file mode
            if (args.file):
                if (args.file == "get"):

                    #read the input file
                    result_list = []
                    csvreader = CsvReader(abspath, tag_input_file,
                                          fieldnames_tag_input)
                    csvwriter = CsvWriter(abspath, resources_output_file,
                                          fieldnames_resource_output)
                    csvwriter.writefile_header()
                    data_list = csvreader.readrows()
                    for row in data_list:
                        res_list = []
                        key = []
                        value = []

                        key.append(row['tagkey'])

                        value.append(row['tagvalue'])
                        if (key[0] != '' and value[0] != ''):
                            res_list = res.get_ec2_resources_on_taginfo(
                                key=key, value=value)