You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sdap.apache.org by GitBox <gi...@apache.org> on 2022/12/05 22:07:49 UTC
[GitHub] [incubator-sdap-nexus] RKuttruff commented on a diff in pull request #220: cdmssubset bugfix
RKuttruff commented on code in PR #220:
URL: https://github.com/apache/incubator-sdap-nexus/pull/220#discussion_r1040150796
##########
analysis/webservice/algorithms/doms/subsetter.py:
##########
@@ -309,16 +300,21 @@ def toCsv(self):
]
data_variables = list(set([keys for result in results for keys in result['data'].keys()]))
data_variables.sort()
+
+ if 'id' in list(set([keys for result in results for keys in result.keys()])):
+ headers.append('id')
+
headers.extend(data_variables)
for i, result in enumerate(results):
cols = []
cols.append(result['longitude'])
cols.append(result['latitude'])
cols.append(datetime.utcfromtimestamp(result['time']).strftime('%Y-%m-%dT%H:%M:%SZ'))
+ cols.append(result.get('id'))
Review Comment:
I think this should only be called if the id header was added. Otherwise I'm seeing csv output with 4 header fields and 5 data fields which is being incorrectly parsed by pandas
Eg:
```
longitude,latitude,time,sea_surface_foundation_temperature
172.625,-29.875,2018-09-29T09:00:00Z,None,19.509003
...
```
Parsed as:
```
>>> csv_data
longitude latitude time sea_surface_foundation_temperature
172.625 -29.875 2018-09-29T09:00:00Z None 19.509003
172.875 -29.875 2018-09-29T09:00:00Z None 18.703003
173.125 -29.875 2018-09-29T09:00:00Z None 18.308990
173.375 -29.875 2018-09-29T09:00:00Z None 18.298004
173.625 -29.875 2018-09-29T09:00:00Z None 18.329010
... ... ... ... ...
171.375 -25.125 2018-09-24T09:00:00Z None 21.669006
171.625 -25.125 2018-09-24T09:00:00Z None 21.360992
171.875 -25.125 2018-09-24T09:00:00Z None 21.075012
172.125 -25.125 2018-09-24T09:00:00Z None 20.730011
172.375 -25.125 2018-09-24T09:00:00Z None 20.737000
[9600 rows x 4 columns]
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@sdap.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org