<commit_before>#!/usr/bin/env python
# this file should read in the csv file, sort into time and voltage
# should also output vector of times of each heartbeat
import csv
import numpy as np


def read_ecg(file='Test_ECG.csv'):
    time = []
    voltage = []
    if file.endswith('.csv'):
        with open (file) as ecg_Data_File:
            ecg_reader = csv.reader(ecg_Data_File)
            next(ecg_reader)
            for row in ecg_reader:
                time.append(row[0])
                voltage.append(row[1])
        return time, voltage
    # else need to insert error message here for if not a csv file!


def find_range(time, voltage, peakthresh = 0.7, basethresh = 0.1):
    toggle_peak_status = 0
    import statistics
    peak_times = []
    baseline = statistics.median(voltage)
    pos_range = max(voltage)-baseline
    for i in voltage:
        if toggle_peak_status == 0:
            if voltage[i] > (baseline + peakthresh * pos_range):
                peak_times.append(time[i])
                toggle_peak_status = 1
        if toggle_peak_status == 1:
            if voltage[i] < (baseline + basethresh * pos_range):
                toggle_peak_status = 0<commit_msg>Made variable to check file type<commit_after>#!/usr/bin/env python
# this file should read in the csv file, sort into time and voltage
# should also output vector of times of each heartbeat
import csv
import numpy as np


def read_ecg(file='Test_ECG.csv'):
    time = []
    voltage = []
    if file.endswith('.csv'):
        with open (file) as ecg_Data_File:
            ecg_reader = csv.reader(ecg_Data_File)
            next(ecg_reader)
            for row in ecg_reader:
                time.append(row[0])
                voltage.append(row[1])
        csv_check = 1
    else:
        csv_check = 0
    return time, voltage, csv_check
    # else need to insert error message here for if not a csv file!


def find_range(time, voltage, peakthresh = 0.7, basethresh = 0.1):
    toggle_peak_status = 0
    import statistics
    peak_times = []
    baseline = statistics.median(voltage)
    pos_range = max(voltage)-baseline
    for i in voltage:
        if toggle_peak_status == 0:
            if voltage[i] > (baseline + peakthresh * pos_range):
                peak_times.append(time[i])
                toggle_peak_status = 1
        if toggle_peak_status == 1:
            if voltage[i] < (baseline + basethresh * pos_range):
                toggle_peak_status = 0
{'fraction_non_alphanumeric': 0.08766233766233766, 'fraction_numerical': 0.00974025974025974, 'mean_word_length': 2.2779255319148937, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '281690', 'n_tokens_mistral': 794, 'n_tokens_neox': 723, 'n_words': 224}