NumPy DateTime Summer of Code Project
martyfuhry/npy_datetime
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Summer of Code Project 2009 Last modification to the README: 7/12/2009 Dependencies ------------------- Currently, the only dependency is the python developer package (python-dev from the Ubuntu repositories). This is required to create a python module out of a C program. Directory Structure -------------------- |-- parsing | |-- Parser_orig.py The original parser for the mxDateTime Parsing Module. | |-- Parser_ts.py The modified parser taken directly from the TimeSeries module. | |-- c_parse.c This is the main parsing file. | |-- old | | |-- a.out | | |-- str_to_int.c | | `-- test_str.c Old attempts at getting callbacks and parsing to work. Nothing to see here. | |-- setup.py Initializes the c_parse.c code into the parsedates module. | |-- test.py Examples on how to run the code and stuff | `-- test.pyc Seting up the Parse Dates -------------------- Navigate to the parsing directory, since the other code is unimportant as of now. $ cd parsing Just like every other distutils: $ python setup.py build $ sudo python setup.py install Or you can just navigate to the .so file generated by build and forgo installing it. On Running This Code -------------------- The module is called parsedates >>> import parsedates as p Since the main goal of the parser is to use a Python program to parse, you need to set up the callback (DateTimeFromString is located in the Parser_ts submodule in parsing/tests >>> import Parser_ts as dt_parse >>> p.set_callback(dt_parse.DateTimeFromString) Now you can actually parse dates using date_to_long(datetime or datestring, freq) >>> date = p.date_to_long("01/01/1970", "D") date_to_long is a wrapper for two functions (datetime_to_long and datestring_to_long). date_to_long decides which to run based on the first argument. It accepts either a Python DateTime object or a string formatted so DateTimeFromString can parse it into a Python DateTime object (see Parser_ts.py for examples on correct string formats). >>>print date 0L date will not store the frequency (yet), but it formats the number based on the frequency (so storing frequency is trivial). The long represents the number of frequency units since Jan 1, 1970 (the Unix Epoch).
About
NumPy DateTime Summer of Code Project
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published