Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jph00 committed Sep 6, 2024
1 parent 9810af7 commit b6708b3
Showing 1 changed file with 50 additions and 2 deletions.
52 changes: 50 additions & 2 deletions nbs/index.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -988,8 +988,13 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Manipulating data\n",
"\n",
"## Manipulating data"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We try to make the following methods as flexible as possible. Wherever possible, they support Python dictionaries, dataclasses, and classes. "
]
},
Expand Down Expand Up @@ -1183,6 +1188,49 @@
"cats.delete(cat.id)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Importing CSV/TSV/etc"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can pass a file name, string, bytes, or open file handle to `import_file` to import a CSV:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[{'id': 1, 'name': 'Alice', 'age': 30},\n",
" {'id': 2, 'name': 'Bob', 'age': 25},\n",
" {'id': 3, 'name': 'Charlie', 'age': 35}]"
]
},
"execution_count": null,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"db = Database(\":memory:\")\n",
"csv_data = \"\"\"id,name,age\n",
"1,Alice,30\n",
"2,Bob,25\n",
"3,Charlie,35\"\"\"\n",
"\n",
"table = db.import_file(\"people\", csv_data)\n",
"table()"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down

0 comments on commit b6708b3

Please sign in to comment.