Files
PythonSampleAppMultipleFiles/sample_app.py

23 lines
884 B
Python

import numpy as np
import matplotlib.pyplot as plt
def main(numbers_files, multiplier):
"""
Example Python application that reads the given numbers_files and multiplies
the content (numbers) by the supplied multiplier
Arguments:
numbers_files: list of paths to input files of type 'text_data'
multiplier: number by which the arrays of numbers are multiplied
Returns:
A file named 'multiplied_numbers_plot.png' containing a plot of multiplied
numbers.
"""
plt.figure()
for numbers_file in numbers_files:
numbers = np.genfromtxt(numbers_file, comments="#", delimiter=",", unpack=False)
numbers = numbers[~np.isnan(numbers)]
numbers = np.array(numbers).flatten()
multiplied_numbers = numbers * multiplier
plt.plot(multiplied_numbers)
plt.savefig('multiplied_numbers_plot.png')