Untitled

mail@pastecode.io avatar
unknown
plain_text
20 days ago
2.7 kB
8
Indexable
Never
"""
Course Number: ENGR 13300
Semester: Fall 2024

Description:
    A program that takes in a csv file and interprets then plots it.

Assignment Information:
    Assignment:     Py4 Team 1
    Team ID:        018 - 02
    Author:         Elias Malak, emalak@purdue.edu
                    Mathew Drenning, mdrennin@purdue.edu
                    Gilberto Morales, moral231@purdue.edu
                    Akram Quol, aquol@purdue.edu
                    Sebastian Berry, berry183@purdue.edu
                    Greg Klein, klein157@purdue.edu
    Date:           09/24/2024

Contributors:
    Name, login@purdue [repeat for each]

    My contributor(s) helped me:
    [ ] understand the assignment expectations without
        telling me how they will approach it.
    [ ] understand different ways to think about a solution
        without helping me plan my solution.
    [ ] think through the meaning of a specific error or
        bug present in my code without looking at my code.
    Note that if you helped somebody else with their code, you
    have to list that person as a contributor here as well.

Academic Integrity Statement:
    I have not used source code obtained from any unauthorized
    source, either modified or unmodified; nor have I provided
    another student access to my code.  The project I am
    submitting is my own original work.
"""
# import necessary libs
import matplotlib.pyplot as plt
from operator import itemgetter
import csv


def main():
    # open the csv file in read mode
    f = open("py4_pre_task0_data.csv", "r")
    csv_data = []
    # grab the data and turn it into usable lists that can be operated on
    for line in f.readlines():
        values = line.split(',')
        values[0] = int(values[0])
        values[1] = int(values[1].strip()) * 4
        csv_data.append(values)
    # close the file to avoid corruption issues
    f.close()

    # create the lists of x values and y values
    xlist = make_list_with_indicie(csv_data, 0)
    ylist = make_list_with_indicie(csv_data, 1)
    plt.scatter(xlist, ylist)

    # defines necessary axis labels and title for professional presentation
    plt.title("Py4_Pre_1_data")
    plt.xlabel('Time (s)')
    plt.ylabel('Original Data * 4')

    # plot graph
    plt.show()
 
    # write the modified list to the csv file
    with open('py4_pre_1_emalak.csv','w', newline='') as csvfile:
        writer = csv.writer(csvfile)
        writer.writerows(csv_data)

# makes a list out of the list of inidicies 
def make_list_with_indicie(specified_list, index):
    return list(map(itemgetter(index), specified_list))


if __name__ == "__main__":
    main()
Leave a Comment