[Numpy-discussion] how to loop read input over various file with same extension in a folder (newbie question)
Paul Anton Letnes
paul.anton.letnes@gmail....
Thu Mar 24 02:53:34 CDT 2011
One way is to use python dicts. Pseudocode:
arrays = {}
integer = 0
for file in allfiles:
integer +=1
data = file.read()
arrays['a' + '%d' % integer] = data
I would consider using the filename as the key instead of a1, a2, etc. That way you have that information readily available as well.
Good luck,
Paul.
On 24. mars 2011, at 08.27, Sachin Kumar Sharma wrote:
> BB,
>
> Currently I am reading a text file and storing the output as an array a1, some arithmetic operation on it and plotting it. I want to do the same over 1000 files.
> How to loop it and how to store the input in different arrays like a2, a3 and so on.
>
> Also advise what is the best way to TAG or assign a comment to an array to store which file it has read the data.
>
> Cheers
>
> Sachin
>
> ************************************************************************
> Sachin Kumar Sharma
> Senior Geomodeler
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
More information about the NumPy-Discussion
mailing list