autocommit 20-05-2024-08-17

This commit is contained in:
Jasen Qin 2024-05-20 08:17:05 +10:00
parent 649d56f992
commit 60b916c4d8
4 changed files with 4 additions and 3 deletions

View File

@ -14,8 +14,9 @@ describe('DATABASE', () => {
}) })
it('create csv', () => { it('create csv', () => {
let res = create_csv_database('csv_db/x.csv', { "a_key": [], "a_value": [] }) let res = create_csv_database('csv_db/x.csv', { "a_key": ['initial'], "a_value": [''] })
print_head(res) print_head(res)
delete_row_by_key(res, "initial", "a_key")
add_row(res, { "a_key": ["x"], "a_value": ["y"] }) add_row(res, { "a_key": ["x"], "a_value": ["y"] })
print_head(res) print_head(res)

View File

@ -17,7 +17,7 @@ export function save_db(db: CSVDatabase) {
} }
export function add_row(db: CSVDatabase, row: any) { export function add_row(db: CSVDatabase, row: any) {
let d = DataFrame([row]) let d = DataFrame(row)
db.df = db.df.vstack(d) db.df = db.df.vstack(d)
} }

View File

@ -42,7 +42,6 @@ export function create_inventory_dataframe(inventories: Inventory[]): CSVDatabas
return create_csv_database(filepath, inventories) return create_csv_database(filepath, inventories)
} }
function create_models() { function create_models() {
const items: Item[] = [ const items: Item[] = [
{ id: '1', name: 'Item 1', price: 100 }, { id: '1', name: 'Item 1', price: 100 },

View File

@ -1 +1,2 @@
a_key,a_value a_key,a_value
x,y

1 a_key a_value
2 x y