{ "cells": [ { "cell_type": "markdown", "id": "1375ea77-6560-434d-8838-2e86a8a02da4", "metadata": {}, "source": [ "# Read a CSV File" ] }, { "cell_type": "code", "execution_count": null, "id": "4678ac3c-f28a-4ca9-a8b4-a15f1eccf4df", "metadata": { "tags": [] }, "outputs": [], "source": [ "import csv" ] }, { "cell_type": "markdown", "id": "18ffa87c-7e76-4674-86a5-611b5a3ed240", "metadata": {}, "source": [ "#### We will get a **list of values** for each row of the CSV file." ] }, { "cell_type": "code", "execution_count": null, "id": "924b1854-2a2d-4197-b870-389f2b35a478", "metadata": { "tags": [] }, "outputs": [], "source": [ "with open('TitanicSurvival.csv', newline='') as csv_file:\n", " data = csv.reader(csv_file, delimiter=',', quotechar='\"')\n", " \n", " for row in data:\n", " print(row)" ] }, { "cell_type": "code", "execution_count": null, "id": "e25adf75-2a7b-46f6-9b06-6e2b6b412883", "metadata": {}, "outputs": [], "source": [ "# Copyright (c) 2023 by Ronald Mak" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.13" } }, "nbformat": 4, "nbformat_minor": 5 }