From 8ed6960e793c98672d124881c96438f2f5ff6399 Mon Sep 17 00:00:00 2001 From: phga Date: Tue, 19 Oct 2021 21:35:58 +0200 Subject: [PATCH] new: melli excel to sql --- data/data.txt | 1 - data/media.txt | 1 - dominik.py | 57 ++++++++++++++++++++++++++++++++++++ flexvolt.py | 64 ----------------------------------------- melli/excel2sql.py | 48 +++++++++++++++++++++++++++++++ melli/test.sql | 24 ++++++++++++++++ melli/test.xlsx | Bin 0 -> 9627 bytes mep.py | 53 ++++++++++++++++++++++++++++++++++ test.py => natascha.py | 0 oop.py | 19 ++++++++++++ 10 files changed, 201 insertions(+), 66 deletions(-) delete mode 100644 data/data.txt delete mode 100644 data/media.txt create mode 100755 dominik.py delete mode 100755 flexvolt.py create mode 100755 melli/excel2sql.py create mode 100644 melli/test.sql create mode 100644 melli/test.xlsx create mode 100644 mep.py rename test.py => natascha.py (100%) create mode 100755 oop.py diff --git a/data/data.txt b/data/data.txt deleted file mode 100644 index 7cc93f9..0000000 --- a/data/data.txt +++ /dev/null @@ -1 +0,0 @@ -I am data (: \ No newline at end of file diff --git a/data/media.txt b/data/media.txt deleted file mode 100644 index 8120143..0000000 --- a/data/media.txt +++ /dev/null @@ -1 +0,0 @@ -I am media :P \ No newline at end of file diff --git a/dominik.py b/dominik.py new file mode 100755 index 0000000..111ba3a --- /dev/null +++ b/dominik.py @@ -0,0 +1,57 @@ +#!/bin/python +# 1 bis 20 +# fizz durch 3 teilbar +# buzz durch 5 teilbar +# durch 3 und 5 teilbar fizzbuzz + +# for z in range(1, 101): +# if z % 3 == 0: +# print("Fizz", end="") +# if z % 5 == 0: +# print("Buzz", end="") +# if z % 3 != 0 and z % 5 != 0: +# print(z, end="") +# print() + + + +# 3 -> Fizz +# 5 -> Buzz +# 13 -> Penis + +def eval_dividers(user_inputs, num): + divisible = False + for curr in user_inputs: + div = curr[0] + word = curr[1] + + if num % div == 0: + print(word, end="") + divisible = True + + return divisible + + +def print_loop(user_inputs, max_number): + for i in range(1, max_number + 1): + if not eval_dividers(user_inputs, i): + print(i) + else: + print() + + +def init(): + # (1, "Ass") + user_input = input("Bitte Zahl und Wort eingeben: ").split(" ") + user_inputs = [] + # user_input = int(input("Test: ")) + while len(user_input) > 1: + user_input[0] = int(user_input[0]) + user_inputs.append(user_input) + user_input = input("Bitte Zahl und Wort eingeben: ").split(" ") + + max_number = int(input("Bitte obere Grenze angeben: ")) + print_loop(user_inputs, max_number) + + +init() diff --git a/flexvolt.py b/flexvolt.py deleted file mode 100755 index 8e90c05..0000000 --- a/flexvolt.py +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/python -# author: phga -# date: 2021-04-08 -# desc: Script that turns flexvolt exports/recordings into 2x2 plots -import os -import seaborn as sns -import matplotlib.pyplot as mp -from pandas import read_csv - -sns.set_theme(style="white", color_codes=True) -sns.set_palette("colorblind") - -plot_dir = "../flexvolt_plots" -typing_tests = [] - -# Collect all tests -for root, sub, files in os.walk("../flexvolt"): - for f in files: - if f.endswith("txt"): - typing_tests.append(os.path.join(root, f)) - -for f in typing_tests: - # Get participants name and datetime for test - subject = f.split("/")[-2] - date_time = f.split("flexvolt-recorded-data--")[-1].strip(".txt") - # Skip first row of meta_data; Only use Processed Data - flex_data = read_csv(f, skiprows=1, usecols=[0,5,6,7,8]) - # Get min values to normalize data - start_time = flex_data["Time (ms)"][0] - min_c1 = flex_data["Chan 1Processed"].min() - min_c2 = flex_data["Chan 2Processed"].min() - min_c3 = flex_data["Chan 3Processed"].min() - min_c4 = flex_data["Chan 4Processed"].min() - # Subtract min values and start time from respective columns - flex_data = flex_data.sub([start_time, min_c1, min_c2, min_c3, min_c4]) - # Convert ms to s - flex_data["Time (ms)"] *= 10**-3 - # Create 2x2 plot - plot, axi = mp.subplots(2, 2) - # Settings for whole image - plot.suptitle(f'{subject}: {date_time}') - mp.subplots_adjust(hspace=0.5, wspace=0.5) - # Subplots - sns.lineplot(x="Time (ms)", y="Chan 2Processed", data=flex_data, ax=axi[0][0]) - sns.lineplot(x="Time (ms)", y="Chan 1Processed", data=flex_data, ax=axi[0][1]) - sns.lineplot(x="Time (ms)", y="Chan 4Processed", data=flex_data, ax=axi[1][0]) - sns.lineplot(x="Time (ms)", y="Chan 3Processed", data=flex_data, ax=axi[1][1]) - # title for each plot and counter var - plot_title = ["Extensor L", "Extensor R", "Flexor L", "Flexor R"] - i = 0 - # Label axis - for rows in axi: - for plot in rows: - plot.set_ylim(-5, 300) - plot.set_title(plot_title[i], fontweight="bold") - plot.set_ylabel("Muscle Signal [µV]", fontsize="x-small") - plot.set_xlabel("Time [s]", fontsize="x-small") - i += 1 - - try: - os.mkdir(f"{plot_dir}/{subject}") - except OSError as error: - pass - mp.savefig(f"{plot_dir}/{subject}/{date_time}.png") \ No newline at end of file diff --git a/melli/excel2sql.py b/melli/excel2sql.py new file mode 100755 index 0000000..4aad133 --- /dev/null +++ b/melli/excel2sql.py @@ -0,0 +1,48 @@ +#!/bin/python3 +import pandas as pd +from argparse import ArgumentParser + +p = ArgumentParser() +# action store_true is for flags +p.add_argument("-i", "--input", nargs="+", help="Path to input excel file") +p.add_argument("-o", "--output", nargs="+", help="Path to output sql file") +args = p.parse_args() + +if not args.input: + in_file_path = input("Please enter path to input excel file: ") +else: + in_file_path = args.input[0] + +if not args.output: + out_file_path = input("Please enter path to output sql file: ") +else: + out_file_path = args.output[0] + + +print(f'Input: {in_file_path}\nOutput: {out_file_path}') + +in_file = pd.ExcelFile(in_file_path) + +with open(out_file_path, "w") as of: + for sheet in in_file.sheet_names: + curr_sheet = in_file.parse(sheet) + # One line is one test subject/object + for line in curr_sheet.iterrows(): + indices = line[1].index + values = line[1].values + # print(indices, values) + cols = "" + vals = "" + for i in range(len(indices)): + if i != 0: + cols += f", {indices[i]}" + vals += f", {values[i]}" + else: + cols += f"{indices[i]}" + vals += f"{values[i]}" + # USE $DB + # INSERT INTO $DB.$TABLE ($COL1, $COL2, ...) VALUES ($VAL1, $VAL2, ...) + db_table = sheet.split(".") + db = db_table[0] + table = db_table[1] + of.write(f"INSERT INTO {db}.{table} ({cols}) VALUES ({vals})\n") diff --git a/melli/test.sql b/melli/test.sql new file mode 100644 index 0000000..d79bf68 --- /dev/null +++ b/melli/test.sql @@ -0,0 +1,24 @@ +INSERT INTO db.tabelle (DB_Saplte_01, DB_Saplte_02, DB_Saplte_03, DB_Saplte_04) VALUES (s1_d1, s2_d1, s3_d1, s4_d1) +INSERT INTO db.tabelle (DB_Saplte_01, DB_Saplte_02, DB_Saplte_03, DB_Saplte_04) VALUES (s1_d2, s2_d2, s3_d2, s4_d2) +INSERT INTO db.tabelle (DB_Saplte_01, DB_Saplte_02, DB_Saplte_03, DB_Saplte_04) VALUES (s1_d3, s2_d3, s3_d3, s4_d3) +INSERT INTO db.tabelle (DB_Saplte_01, DB_Saplte_02, DB_Saplte_03, DB_Saplte_04) VALUES (s1_d4, s2_d4, s3_d4, s4_d4) +INSERT INTO db.tabelle (DB_Saplte_01, DB_Saplte_02, DB_Saplte_03, DB_Saplte_04) VALUES (s1_d5, s2_d5, s3_d5, s4_d5) +INSERT INTO db.tabelle (DB_Saplte_01, DB_Saplte_02, DB_Saplte_03, DB_Saplte_04) VALUES (s1_d6, s2_d6, s3_d6, s4_d6) +INSERT INTO db.tabelle (DB_Saplte_01, DB_Saplte_02, DB_Saplte_03, DB_Saplte_04) VALUES (s1_d7, s2_d7, s3_d7, s4_d7) +INSERT INTO db.tabelle (DB_Saplte_01, DB_Saplte_02, DB_Saplte_03, DB_Saplte_04) VALUES (s1_d8, s2_d8, s3_d8, s4_d8) +INSERT INTO db.tabelle (DB_Saplte_01, DB_Saplte_02, DB_Saplte_03, DB_Saplte_04) VALUES (s1_d9, s2_d9, s3_d9, s4_d9) +INSERT INTO db.tabelle (DB_Saplte_01, DB_Saplte_02, DB_Saplte_03, DB_Saplte_04) VALUES (s1_d10, s2_d10, s3_d10, s4_d10) +INSERT INTO db.tabelle (DB_Saplte_01, DB_Saplte_02, DB_Saplte_03, DB_Saplte_04) VALUES (s1_d11, s2_d11, s3_d11, s4_d11) +INSERT INTO db.tabelle (DB_Saplte_01, DB_Saplte_02, DB_Saplte_03, DB_Saplte_04) VALUES (s1_d12, s2_d12, s3_d12, s4_d12) +INSERT INTO db2.tab2 (DB_LELE_01, DB_LALA_02) VALUES (s1_d1, s2_d1) +INSERT INTO db2.tab2 (DB_LELE_01, DB_LALA_02) VALUES (s1_d2, s2_d2) +INSERT INTO db2.tab2 (DB_LELE_01, DB_LALA_02) VALUES (s1_d3, s2_d3) +INSERT INTO db2.tab2 (DB_LELE_01, DB_LALA_02) VALUES (s1_d4, s2_d4) +INSERT INTO db2.tab2 (DB_LELE_01, DB_LALA_02) VALUES (s1_d5, s2_d5) +INSERT INTO db2.tab2 (DB_LELE_01, DB_LALA_02) VALUES (s1_d6, s2_d6) +INSERT INTO db2.tab2 (DB_LELE_01, DB_LALA_02) VALUES (s1_d7, s2_d7) +INSERT INTO db2.tab2 (DB_LELE_01, DB_LALA_02) VALUES (s1_d8, s2_d8) +INSERT INTO db2.tab2 (DB_LELE_01, DB_LALA_02) VALUES (s1_d9, s2_d9) +INSERT INTO db2.tab2 (DB_LELE_01, DB_LALA_02) VALUES (s1_d10, s2_d10) +INSERT INTO db2.tab2 (DB_LELE_01, DB_LALA_02) VALUES (s1_d11, s2_d11) +INSERT INTO db2.tab2 (DB_LELE_01, DB_LALA_02) VALUES (s1_d12, s2_d12) diff --git a/melli/test.xlsx b/melli/test.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..d862b09bf51170601428ebbe67313adde1193779 GIT binary patch literal 9627 zcmc(F1ymf{vNld|hv4pk0YV58B)Gc;4Kgr;4GbPUxCIFWPw*hYftEbMAe2y}Q@Cq!Sf+@>2p03~T2oOb2puvKIsZ9L+#LTN6i4h&|8_cEth$wKZ{q z{e)Tq>`lz9O)P-`9xg6EfY~ora5&vsK_~J=5@=!KY~w^jBjpCO?iWK`Z7t|%el_=2 zmoOdJ_Evx!$L$rs--GP!EdLgCd;T9FR`$TZ$NaqT4YC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=lsr#bU0wHm9r_X%1?nRcis}G;cPt4Tz6bAJ>E_4cwutG# zQoNES^5c1~(+UnmCDAKzNsV30fo>CQuSjw%KP7)tXDJ)bG8pX|8n~T7l;1jgD?NV{ zGg!Zh(u~DWZ9(*=-sE-VczhMSsFvdlXfVX zJy6aLcsWG4Om{8;b_}EsFQ=|}!q-~n&Zv|`47ub|<=`ZPBPsb#K764XocP$A-tLD# z=r)abKE2Ju;+#JE@YMyYOS|6+Pw;2YEeD)2Jmv&7vtTlhafe9>=k|3Tt0h%}`8wmn zSNy6+`4UQATi#uso%YUap>9&A)rlPF3+*)d6;Jyh`&G}9_tZ2(w%-%Q+qbr^sZKfCvOn98bg+`K z*W@)IaTDJz_?xJv0(++17syg4#j4?mZi$7Eh1#hDiSGC%v0Y8N66%JVdbjM~sAOY$6GXv--K-{FeVE2IPhnN?k@Q5O4}{$7jQi4FRLEEue;ra-d!U314;s$ zZ(w@=zXg-K67I79e@O6#Ee8B)E#NNjE>HdkFcR}`So6E^yEO10@EzD{Sv`U4xDLA9&Hba_(}4f5=gWanmq4e|n6&We)G+?>_kbfo~zci~rdz-W71S z%ltz?JdEM}HE{m?O2^+yxm#rZkn)x4Z>9V!IjRcCu;7G)!-V~zz)F-4-R-ac2lNCt A7ytkO literal 0 HcmV?d00001 diff --git a/mep.py b/mep.py new file mode 100644 index 0000000..b3fe9bf --- /dev/null +++ b/mep.py @@ -0,0 +1,53 @@ +def getMedian(list1, list2): + list1.extend(list2) + for i in range(len(list1) - 1): + minimum = i + for j in range( i + 1, len(list1)): + if(list1[j] < list1[minimum]): + minimum = j + if(minimum != i): + list1[i], list1[minimum] = list1[minimum], list1[i] + if len(list1) % 2 == 0: + index = int(len(list1) / 2) + median = (list1[index] + list1[index-1]) / 2 + else: + index = int((len(list1) - 1) / 2) + median = list1[index] + return float(median) +# ↑ ↑ ↑ Your Code ↑ ↑ ↑ +tests = 0 +passed = 0 +def test(nums1, nums2, output): + median = getMedian(nums1, nums2) + print("Array: Nums1: "+str(nums1)+" Nums2: "+str(nums2)) + print("Median expected: "+str(output)) + print("Median got: "+str(median)) + print("Is Median equal: "+str(median == output)) + print() + global tests, passed + tests = tests + 1 + passed = passed + 1 if median == output else passed + 0 + +nums1 = [1,3] +nums2 = [2] +output = 2.00000 +test(nums1, nums2, output) +nums1 = [1,2] +nums2 = [3,4] +output = 2.50000 +test(nums1, nums2, output) +nums1 = [0,0] +nums2 = [0,0] +output = 0.00000 +test(nums1, nums2, output) +nums1 = [] +nums2 = [1] +output = 1.00000 +test(nums1, nums2, output) +nums1 = [2] +nums2 = [] +output = 2.00000 +test(nums1, nums2, output) + +print(str(tests)+" Tests") +print(str(passed)+" Passed/"+str(tests-passed)+" Failed") \ No newline at end of file diff --git a/test.py b/natascha.py similarity index 100% rename from test.py rename to natascha.py diff --git a/oop.py b/oop.py new file mode 100755 index 0000000..99e2907 --- /dev/null +++ b/oop.py @@ -0,0 +1,19 @@ +#!/bin/python + +########################################################### + +class Mensch(): + + def __init__(self, name): + self.name = name + + def sprechen(self, text): + print(f"Ich bin {self.name} und ich sage: {text}") + +########################################################### + +domi = Mensch("Dominik") +domi.sprechen("Du netter Kerl!") + +phil = Mensch("Philip") +phil.sprechen("Du tolles Weib..") \ No newline at end of file