more useful options | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Hello, first I describe my use case. I need to process a file full of dates with one specific format (%Y.%m.%d,%H:%M). You can see that the precision I will be working with is minutes. Here goes a snippet of the input: Unfortunately the arithmetical progression pattern you would deduce is not always exact. First, there are no data for weekends (but the hour and minute progression is usually preserved) and second, there are unfortunately some gaps so 13:40 can be followed by 13:50. This apeears to be quite rare but prevents me from handle the data in a nicer way. And now the goal: I will process the file once by picking 1st date and then comparing next N dates to it until the difference is say 12 hours. (I will definitely not want to compare dates in more detail than hours.) Before each comparing I will do some stuff with the row. After I reach specified time I will proceed with comparing Nth date to next M dates until the difference is again 12 hours and so on. As I am not very experienced (Perl) coder I first searched CPAN for the right module to use and was quite overwhelmed (and confused) by the rich selection of modules concerning date and time manipulation. Because I will process my file tens of thousands times (each time with different parameters) and it has cca. 1M of rows the time complexity will be quite a concern. Not that my program will be used in any real time apllications but it will be nice if it runs 10 mins instead of 10 hours. For the date-string parsing part I will probably use DateTime::Format::Strptime so the result will be DateTime object. But what with the comparisons? Should I add specified duration (12 hours) to one object and then compare the two using 'compare' method or first compute the difference in hours and than compare it (as a plain number) with my time interval? Also is there some preferred way how to make use of the fact that for each few hundreds of succesive comparisons one of the objects remains constant or will Perl (or chosen module) do some sort of caching for me? Last I would like to emphasize again that I can surely do all this somehow but I want to do it also quite fast (but not at too much expense of readability). In reply to Which DateTime:: module to use? by kejv2
|
|