{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "f = open('data/ml-1m/ratings.dat')\n", "i = 0\n", "for line in f: \n", " if (i >= 40):\n", " print(line)\n", " i = i + 1\n", " if (i >= 45): break" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "f2 = open('data/tmp.dat', \"w\")\n", "f2.write(\"hello class!\")\n", "f2.write(\"I think you have the hang of Python. You agree?\")\n", "f2.close()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.6.5" } }, "nbformat": 4, "nbformat_minor": 2 }