Creating a table and calculating min from a txt file

I want to ask the user to send a txt file for evaluation, then I need to set up the table and calculate certain things (max, min, sum, etc.) where I am at a dead end - how to set up the table, I am to print and how to find the maximum , minimum and amount based on column specifications.

my code is still ----

def main():    
    my_list = [[float(i) for i in line.split(',')] for line in open("Alpha.txt")]
    print(my_list)
    my_list_one = my_list[0]
    my_list_two = my_list[1]
    my_list_three = my_list[2]
    my_list_four = my_list[3]


main()

All this is done, the Alpha.txt file is read and splits the data lines into separate lists. What I am trying to do is put them in a table like this ...

-----------------------------------------------
|     |   A   |   B   |   C   |   D   |   E   |
-----------------------------------------------
|   1 | 5.00  | 2.00  | 6.00  | 4.00  | 5.00  |
|   2 | 3.00  | 7.00  | 8.00  | 7.00  | 9.00  |
|   3 | 1.10  | 2.20  | 5.80  | 0.10  | 1.30  |
-----------------------------------------------

to format the table, I would just use basic row formatting, e.g.

my_str = "| {:>12.10f} | {:^3d} | {:>12d} |".format(10**(-i), i, 10**i)

, , , lette, ex A, min 5,00, 3,00 1,00, if else .

!

[[1.2, 4.3, 7.0, 0.0], [3.0, 5.0, 8.2, 9.0], [4.0, 3.0, 8.0, 5.6], [8.0, 4.0, 3.0, 7.4]]
+4
1

, Pandas - . Pandas . CSV csv ( csv).

csv

, csv:

CSV , . csv , :

data1,data2
1,6
2,7
3,8
4,9
5,10

, CSV, , :

def read_csv_file():
    import csv, os
    this_dir = os.path.abspath(os.path.dirname(__file__))
    csv_file = this_dir+"/sample_data.csv"
    data1_list=[]
    data2_list=[]
    with open(csv_file, 'rb') as csvfile:
        csv_reader = csv.DictReader(csvfile, dialect= 'excel')
        print "1st data row:"
        for csv_row in csv_reader:
            data1_list.append(csv_row["data1"])
            print csv_row["data1"]
            data2_list.append(csv_row["data2"])
    return data1_list, data2_list

def calculate_min(data1):
    from operator import itemgetter
    minimum_data1=min(enumerate(data1), key=itemgetter(1))[1]
    max_data1=max(enumerate(data1), key=itemgetter(1))[1]
    print "the min of the set was: %s"%minimum_data1
    print "the max of the set was: %s"%max_data1

:

data1, data2 = read_csv_file()
calculate_min(data1)

:

1st data row:
1
2
3
4
5
the min of the set was: 1
the max of the set was: 5

, , , , .

, !

-

0

All Articles