Skip to content
This repository has been archived by the owner on Apr 30, 2022. It is now read-only.

add exporting table files #120

Merged
merged 18 commits into from
Oct 19, 2018
Merged

add exporting table files #120

merged 18 commits into from
Oct 19, 2018

Conversation

fengshuo
Copy link
Contributor

@fengshuo fengshuo commented Oct 10, 2018

  • Add capability to export tables from within the Python package (see here for more info)
  • Update documentation

@fengshuo fengshuo self-assigned this Oct 10, 2018
@fengshuo fengshuo removed their assignment Oct 12, 2018
from .message import Message


def bulkdownloadtable(datatable_code, **kwargs):
Copy link
Contributor

@jjmar jjmar Oct 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function should be bulk_download_table to follow python convention.

Although now I see theres already a bulkdownload function - maybe it would make sense to keep this name the way it is now to keep consistency.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah i was following the bulkdownload for timeseries data

return file_path
else:
print(Message.LONG_GENERATION_TIME)
self._url_request(file_or_folder_path, **options)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct me if I'm wrong but doesn't this line prevent the sleep(30) from being run since it will always continue to recurse on _url_request?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yeah i changed the order here yesterday good catch

@jjmar
Copy link
Contributor

jjmar commented Oct 12, 2018

Theres documentation for quandl.bulkdownload, we should probably add some for this new function as well

if ApiConfig.api_version:
options['params']['api_version'] = ApiConfig.api_version

if list(options.keys()):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean if options['params']:?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated this part since this api doesn't need to support more parameters now


file_path = file_or_folder_path
if os.path.isdir(file_or_folder_path):
file_path = file_or_folder_path + '/' + code_name.replace('/', '_') + '.zip'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will probably be better: file_path = os.path.join(file_or_folder_path, '{}.{}'.format(code_name.replace('/', '_') , 'zip')

def setUpClass(cls):
httpretty.enable()
httpretty.register_uri(httpretty.GET,
re.compile(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason for such formatting?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure, I was looking at the old tests...

@@ -48,3 +50,46 @@ def test_dataset_column_names_match_expected(self):
metadata = Datatable('ZACKS/FC').data_fields()
six.assertCountEqual(self,
metadata, [u'datatable_code', u'id', u'name', u'vendor_code'])


class BulkDownloadDataTableTest(unittest.TestCase):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need any positive test case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added one positive test case

FOR_ANALYSTS.md Outdated
```
After the download is finished, the filename of the downloaded zip file will be returned.

Sometime it takes a while to generate the zip file, you'll get a message while the file is being generated. Once the file is generated, it will start download the zip file.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small grammar issues- should say Sometimes instead of Sometime. Also it will start download the should be it will start the download of the

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha, will update!

```
After the download is finished, the filename of the downloaded zip file will be returned.

Sometime it takes a while to generate the zip file, you'll get a message while the file is being generated. Once the file is generated, it will start download the zip file.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same grammar issue as I posted in the other doc file

README.md Outdated
@@ -117,6 +117,8 @@ The following are instructions for running our tests:
`python setup.py install`
4. Run the following command to test the plugin in all versions of python we support:
`tox`

Once you have all required package installed, you can run tests locally with `python -m unittest -v test.[test file name].[test case name].[individual test name]`.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Should be packages,
  • -v, which stands for verbose, is optional,
  • Shouldn't it be class name instead of test case name?
  • Also, this is to run individual tests. Users will most likely be interested in running all tests which can be accomplished by python -m unittest

return file_path
else:
print(Message.LONG_GENERATION_TIME)
sleep(30)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you put this 30 seconds waiting time into a config file or define it as const variable with meaningful?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea


return self._url_request(file_or_folder_path, **options['params'])

def _url_request(self, file_or_folder_path, **options):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you refactoring this method smaller and easy to read?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

README.md Outdated

Once you have all required package installed, you can run tests locally with:

```ptyhon
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spelling.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😂

README.md Outdated
@@ -117,6 +117,24 @@ The following are instructions for running our tests:
`python setup.py install`
4. Run the following command to test the plugin in all versions of python we support:
`tox`

Once you have all required package installed, you can run tests locally with:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be packages

README.md Outdated

python -W always setup.py -q test

# runnging an individual test

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo. running

README.md Outdated

python -m unittest test.[test file name].[class name].[individual test name]`

# such as

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps Example: is better than such as.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all updated

quandl.export_table('MER/F1', params={'compnumber': '39102', 'mapcode':'-5370','reporttype': 'A', 'qopts': {'columns': ['reportdate', 'amount']}})
```

After the download is finished, the filename of the downloaded zip file will be returned.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you still returning the filename? I think you changed the method to only print the filename.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

if 'params' not in options:
options['params'] = {}

while True:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

status = false
while !status:
            status = self._request_file_info(file_or_folder_path, **options['params'])
            if !status
                 sleep(self.WAIT_GENERATION_INTERVAL)

@fengshuo fengshuo merged commit 579b682 into master Oct 19, 2018
@fengshuo fengshuo deleted the CP-7116/python-download branch October 19, 2018 16:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants