def test_use_case_csv_json(self): """Simple use case using core tools for reading, computing and writing""" raised = False try: data = dr.DataReader(data=data_paths['csv'], f_format='csv').read() table = st.StashTable(data=data, table='data') table.save() subset = table.get(key='gender', value='Female', operator='==', reindex=True) dw.write_json(data=subset, file='subset.json', allow_nan=False, sort_keys=False) dw.write_json(data=subset, file='subset.json', allow_nan=True, sort_keys=True) table.un_stash() os.remove('subset.json') except: raised = True self.assertIs(raised, False)
def test_write_json_indent(self): """Write to json with indent""" data = dr.DataReader(f_format='csv', data=cwd + '/test/data/basic_csv.csv') \ .read(delim=',') dw.write_json(data=data, file='tmp.json', allow_nan=True, indent=4) self.assertIs(os.path.isfile('tmp.json'), True) os.remove('tmp.json')
def test_write_json_not_allow_nan(self): """Write to json not allowing nan""" data = dr.DataReader(f_format='csv', data=cwd + '/test/data/basic_csv.csv') \ .read(delim=',') dw.write_json(data=data, file='tmp.json', allow_nan=False) self.assertIs(os.path.isfile('tmp.json'), True) os.remove('tmp.json')