'Problem by using for loop when loading data series from .csv file and save them as array matrix for every columns loaded

I want to load a series of data from 6 CSV files and save them per column of the data series. As I call the Column_A, Column_B and new_Column_A, only the last output array of the data series which is the 6th CSV file is saved. Is there a possible way or function that could make me save the array of every data series of every CSV file at the end of the for loop?

Below is the code that I have so far:

for n in range(1,7):
    data = np.genfromtxt('data' + str(n) + '_.csv', delimiter=",")

    Column_A = data[35, :]
    Column_A = np.flip(Column_A ) 
    Column_A = np.reshape(Column_A , (len(Column_A )))

    new_Column_A = np.cumsum(Column_A )

    Column_B = data[0, :]
    Column_B = np.flip(Column_B ) # Reverse Array
    Column_B  = np.reshape(Column_B , (len(Column_B )))

print(Column_A)
print(Column_B)
print(new_Column_A)


Solution 1:[1]

I also strongly recommend you use pandas. It's convenient unless your csv file is tremendous. You can use

pd.read_csv

to load 6 csv files then concatenate them into a new file.

this link may help. https://pandas.pydata.org/docs/reference/index.html

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Anson