Skip to main content

This repository which was created to facilitate working with csv

Project description

csv_file library

Author R.A.Vidonchikov

This library provides the ability to read a csv file, find the maximum and minimum elements in the matrix, plot the values of the matrix elements, and also transpose the matrix to another csv file.

def __init__(self, road, new_road):
    self.road = road
    self.results = []
    self.line = 0
    self.column = 0
    self.new_road = new_road

def reader_csv_file(self):
    """Reads a CSV file and print it as a list of rows."""
    with open(self.road, newline='', encoding='utf-8') as file:
        inp = csv.reader(file, delimiter=';', quotechar=',', quoting=csv.QUOTE_NONE)
        for row in inp:
            self.line += 1
            self.column = 0
            for number in row:
                self.column += 1
                number = int(float(number))
                self.results.append(number)

def finder_max(self):
    maximum = np.amax(self.results)
    return maximum

def finder_min(self):
    minimum = np.amin(self.results)
    return minimum

def graph(self):
    x_list = list(range(0, len(self.results)))
    y1_list = list(self.results)
    fig, ax = plt.subplots(figsize=(10, 5))
    ax.set_title('Демонстрация заполения матрицы')
    ax.set_ylabel('Числа матрицы')
    plt.plot(x_list, y1_list)
    plt.ylabel("", fontsize=14, fontweight="bold")
    plt.show()

def transpose(self):
    matrix = np.asarray(self.results).reshape(-1, self.column)
    matrix = matrix.transpose()
    with open(self.new_road, "w", newline='') as f:
        for row in matrix:
            print(' '.join(map(repr, row)), file=f)

Project details


Release history Release notifications | RSS feed

This version

1.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

csv_file-1.0.tar.gz (2.2 kB view hashes)

Uploaded Source

Built Distribution

csv_file-1.0-py3-none-any.whl (2.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page