parent
d40d122941
commit
8ed6960e79
@ -1 +0,0 @@
|
|||||||
I am data (:
|
|
@ -1 +0,0 @@
|
|||||||
I am media :P
|
|
@ -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()
|
@ -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")
|
|
@ -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")
|
@ -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)
|
Binary file not shown.
@ -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")
|
@ -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..")
|
Loading…
Reference in new issue