Skip to content

Commit 4ea0d9e

Browse files
Jorge Fernandez Hernandezbsipocz
authored andcommitted
EUCLIDPCR-1971 Changed suggested in the PR: the astropy Table.read makes use of the format and the documentation of the parameter format has been improved.
1 parent 3e488cd commit 4ea0d9e

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

astroquery/utils/tap/core.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515
"""
1616
import getpass
1717
import os
18-
import requests
1918
import tempfile
20-
from astropy.table.table import Table
2119
from urllib.parse import urlencode
2220

21+
import requests
22+
from astropy.table.table import Table
23+
2324
from astroquery import log
2425
from astroquery.utils.tap import taputils
2526
from astroquery.utils.tap.conn.tapconn import TapConn
@@ -1342,7 +1343,8 @@ def upload_table(self, *, upload_resource=None, table_name=None, table_descripti
13421343
table_description : str, optional, default None
13431344
table description
13441345
format : str, optional, default 'votable'
1345-
resource format
1346+
resource format. Only formats described in
1347+
https://docs.astropy.org/en/stable/io/unified.html#built-in-table-readers-writers are accepted.
13461348
verbose : bool, optional, default 'False'
13471349
flag to display information about the process
13481350
"""
@@ -1415,7 +1417,7 @@ def __uploadTableMultipart(self, resource, *, table_name=None, table_description
14151417
chunk = f.read()
14161418
files = [['FILE', os.path.basename(resource), chunk]]
14171419
else:
1418-
table = Table.read(str(resource))
1420+
table = Table.read(str(resource), format=resource_format)
14191421
fh = tempfile.NamedTemporaryFile(delete=False)
14201422
table.write(fh, format='votable')
14211423
fh.close()

astroquery/utils/tap/tests/test_tap.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,7 +1032,7 @@ def test_upload_table():
10321032

10331033
file_ecsv = get_pkg_data_filename(os.path.join("data", 'test_upload_file', '1744351221317O-result.ecsv'),
10341034
package=package)
1035-
job = tap.upload_table(upload_resource=file_ecsv, table_name=table_name, format='ecsv')
1035+
job = tap.upload_table(upload_resource=file_ecsv, table_name=table_name, format='ascii.ecsv')
10361036

10371037
assert (job.jobid == jobid)
10381038

@@ -1061,7 +1061,7 @@ def test_upload_table():
10611061
with pytest.raises(IORegistryError) as exc_info:
10621062
job = tap.upload_table(upload_resource=file_json, table_name=table_name, format='json')
10631063

1064-
argument_ = "Format could not be identified based on the file name or contents, please provide a 'format' argument."
1064+
argument_ = "No reader defined for format 'json' and class 'Table'."
10651065
assert (argument_ in str(exc_info.value))
10661066

10671067
# Make use of an astropy table

0 commit comments

Comments
 (0)