|
16 | 16 | from pandas import to_datetime
|
17 | 17 | from io import StringIO
|
18 | 18 | import logging
|
| 19 | +import json |
19 | 20 |
|
20 | 21 | DOMO = """####################################################################################################
|
21 | 22 | ####################################################################################################
|
@@ -195,21 +196,16 @@ def ds_get(self, dataset_id):
|
195 | 196 | df[col] = to_datetime(df[col])
|
196 | 197 | except ValueError:
|
197 | 198 | pass
|
| 199 | + except TypeError: |
| 200 | + pass |
198 | 201 |
|
199 | 202 | return df
|
200 | 203 |
|
201 |
| - def ds_create(self, df_up, name, description=''): |
202 |
| - dsr = DataSetRequest() |
203 |
| - dsr.name = name |
204 |
| - dsr.description = description |
205 |
| - dsr.schema = Schema([Column(ColumnType.STRING, 'tt1'), |
206 |
| - Column(ColumnType.STRING, 'tt2')]) |
207 |
| - |
208 |
| - new_ds_info = self.datasets.create(dsr) |
209 |
| - |
210 |
| - self.utilities.stream_upload(new_ds_info['id'],df_up,warn_schema_change=False) |
211 |
| - |
212 |
| - return new_ds_info['id'] |
| 204 | + def ds_create(self, df_up, name, description='', update_method='REPLACE', key_column_names=''): |
| 205 | + new_stream = self.utilities.stream_create(df_up, name, description, update_method, key_column_names) |
| 206 | + ds_id = json.loads(new_stream.content.decode('utf-8'))['dataSet']['id'] |
| 207 | + self.utilities.stream_upload(ds_id,df_up,warn_schema_change=False) |
| 208 | + return ds_id |
213 | 209 |
|
214 | 210 |
|
215 | 211 | def ds_update(self, ds_id, df_up):
|
|
0 commit comments