Looping through a bunch of files? [message #92864] |
Tue, 15 March 2016 11:29  |
wdolan
Messages: 29 Registered: June 2015
|
Junior Member |
|
|
I am a total beginner, and would very much love any assistance!
So I am looking at .nc files. There is one file for every day of the year, they are all in the same folder called /home/nc_d/, and each file has the same internal structure, and are named in the format gc_daily.20130130, varying based only on the date.
I want to figure out how many files there are for each month, and then loop through all the files of a given month.
I'm not sure where to start!
I've used n_elements to tell how many files are in an array before, but that doesn't seem to apply to files....
Thanks for your help.
|
|
|
Re: Looping through a bunch of files? [message #92865 is a reply to message #92864] |
Tue, 15 March 2016 11:43   |
wdolan
Messages: 29 Registered: June 2015
|
Junior Member |
|
|
Just to clarify, I want a way to tell how many files (which each correspond to a day) there are for each month. Just to note, not all days have files, so I can't just assume that there are 28 files for February for example.
and I misspoke in my original post when I said how I used n_elements. It was used to tell the number of elements in an array. not the number of files.
On Tuesday, March 15, 2016 at 11:29:06 AM UTC-7, Wayana Dolan wrote:
> I am a total beginner, and would very much love any assistance!
>
> So I am looking at .nc files. There is one file for every day of the year, they are all in the same folder called /home/nc_d/, and each file has the same internal structure, and are named in the format gc_daily.20130130, varying based only on the date.
>
> I want to figure out how many files there are for each month, and then loop through all the files of a given month.
>
> I'm not sure where to start!
>
> I've used n_elements to tell how many files are in an array before, but that doesn't seem to apply to files....
>
> Thanks for your help.
|
|
|
Re: Looping through a bunch of files? [message #92866 is a reply to message #92865] |
Tue, 15 March 2016 13:28   |
Paul Van Delst[1]
Messages: 1157 Registered: April 2002
|
Senior Member |
|
|
http://www.harrisgeospatial.com/docs/FILE_SEARCH.html
One way would be to construct your "path specification" to reflect a
particular month.
On 03/15/16 14:43, Wayana Dolan wrote:
> Just to clarify, I want a way to tell how many files (which each
> correspond to a day) there are for each month. Just to note, not all
> days have files, so I can't just assume that there are 28 files for
> February for example.
>
> and I misspoke in my original post when I said how I used n_elements.
> It was used to tell the number of elements in an array. not the
> number of files.
>
> On Tuesday, March 15, 2016 at 11:29:06 AM UTC-7, Wayana Dolan wrote:
>> I am a total beginner, and would very much love any assistance!
>>
>> So I am looking at .nc files. There is one file for every day of
>> the year, they are all in the same folder called /home/nc_d/, and
>> each file has the same internal structure, and are named in the
>> format gc_daily.20130130, varying based only on the date.
>>
>> I want to figure out how many files there are for each month, and
>> then loop through all the files of a given month.
>>
>> I'm not sure where to start!
>>
>> I've used n_elements to tell how many files are in an array before,
>> but that doesn't seem to apply to files....
>>
>> Thanks for your help.
|
|
|
Re: Looping through a bunch of files? [message #92868 is a reply to message #92866] |
Tue, 15 March 2016 15:30  |
wdolan
Messages: 29 Registered: June 2015
|
Junior Member |
|
|
Hi Paul,
That worked, thank you!
On Tuesday, March 15, 2016 at 1:28:48 PM UTC-7, Paul van Delst wrote:
> http://www.harrisgeospatial.com/docs/FILE_SEARCH.html
>
> One way would be to construct your "path specification" to reflect a
> particular month.
>
>
> On 03/15/16 14:43, Wayana Dolan wrote:
>> Just to clarify, I want a way to tell how many files (which each
>> correspond to a day) there are for each month. Just to note, not all
>> days have files, so I can't just assume that there are 28 files for
>> February for example.
>>
>> and I misspoke in my original post when I said how I used n_elements.
>> It was used to tell the number of elements in an array. not the
>> number of files.
>>
>> On Tuesday, March 15, 2016 at 11:29:06 AM UTC-7, Wayana Dolan wrote:
>>> I am a total beginner, and would very much love any assistance!
>>>
>>> So I am looking at .nc files. There is one file for every day of
>>> the year, they are all in the same folder called /home/nc_d/, and
>>> each file has the same internal structure, and are named in the
>>> format gc_daily.20130130, varying based only on the date.
>>>
>>> I want to figure out how many files there are for each month, and
>>> then loop through all the files of a given month.
>>>
>>> I'm not sure where to start!
>>>
>>> I've used n_elements to tell how many files are in an array before,
>>> but that doesn't seem to apply to files....
>>>
>>> Thanks for your help.
|
|
|