How to append horizontally the data array from the FOR loop?

Madhavan Bomidi blmadhavan at gmail.com
Fri May 10 11:08:33 EDT 2019


Hi,

I have to append requisite data matrix from multiple files into a single variable using FOR loop.

outData = [];

for file in fileList:
   ....
   ....
   ....
   allData = ....                # an array of nrows and ncols.
   outData = [outData; allData]  # in MATLAB

While the ncols are constant, the nrows will vary. My intention is to append the allData (with variable rows) from each file into the outData. 

1. Can anyone suggest how I can do this with an example?

2. How can I save this outData (data matrix) with delimiter (comma) and precision of '%8.5f' or any other into a .txt or .csv file or any other type?

3. How can I append the header on the top of this output file?

Thanks in advance



More information about the Python-list mailing list