[Tutor] suggestions for splitting file based on date
Sivaram Neelakantan
nsivaram.net at gmail.com
Sat Jul 20 06:53:43 CEST 2013
On Sat, Jul 20 2013,Peter Otten wrote:
> Sivaram Neelakantan wrote:
[snipped 16 lines]
> I'd start with a single list for the complete data, reverse that using the
> aptly named method and then create the three smaller lists using slicing.
>
> For example:
>
>>>> stock_data = range(10)
>>>> stock_data.reverse()
>>>> stock_data
> [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
>>>> stock_data[:3] # the last three days
> [9, 8, 7]
>
> On second thought I don't see why you want to reverse the data. If you omit
> that step you need to modify the slicing:
>
>>>> stock_data = range(10)
>>>> stock_data[-3:] # the last three days
> [7, 8, 9]
>
Thank you, this is as simple as it gets. The only wiggle is the
trading day versus the calendar day. If I use the trading day, the
above slicing will work(a simple numerical count, to represent 30
*trading* day window) but the calendar day is a lot more hops
accounting for weekends or days of no trading. I believe I'd have to
end up doing a date compare.
[snipped 7 lines]
sivaram
--
More information about the Tutor
mailing list