On 10/05/2019 16:08, Madhavan Bomidi wrote:
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?

I don't do homework :-) What format are your input files in? Is there something that will already that for you? Python comes with "batteries included", i.e. there are many modules in the standard library that will likely make life easier.

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?

Have you looked at the csv module in the standard library?

--
Rhodri James *-* Kynesim Ltd
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to