Add materials for Reading and Writing CSV Files in Python - #841
Open
realpython-bot wants to merge 1 commit into
Open
realpython-bot wants to merge 1 commit into
realpython-bot wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a NEW folder for a tutorial that has never had companion code, so it needs an editorial eye as well as a code review — there is no previous version of
python-csv/to diff against.Source of truth: the updated draft, not the live article.
What the folder contains
Six scripts, one per code-bearing section of the tutorial, in article order:
read_csv_with_reader.pycsvread_csv_into_dictionary.pycsvwrite_csv_with_writer.pycsvwrite_csv_from_dictionary.pycsvread_csv_with_pandas.pypandaswrite_csv_with_pandas.pypandasPlus the three data files the article shows —
employee_birthday.csv,employee_addresses.csv,hrdata.csv— aREADME.md, and arequirements.txtpinned to the draft'sdependenciesfield (pandas==3.0.5; the draft also pinspython==3.14, which isn't a pip requirement).The files the tutorial generates (
employee_file.csv,employee_file2.csv,hrdata_modified.csv) are deliberately not checked in — running the writing scripts produces them. The README says so.REPL examples were turned into runnable scripts
The tutorial's two
pyconblocks (thetype()checks ondf['Hire Date']) are not shipped as separate snippets. They're folded intoread_csv_with_pandas.pyasprint()calls at exactly the point in the section where the article shows them, so the whole "Reading CSV Files Withpandas" progression runs top to bottom as one coherent script with the article's own variable names and ordering. No examples were invented and no code was "improved" beyond the repo's formatter.How it was verified
pandas==3.0.5.<class 'str'>,<class 'pandas.Timestamp'>, and all fourDataFramerenderings.requirements.txtpins:uvx ruff@0.14.1 format --check python-csvanduvx ruff@0.14.1 check python-csvboth pass.Note for review:
ruff formatrewrote the article's single quotes to double quotes and wrapped a few long calls, so the shipped code is house-formatted rather than a character-for-character copy of the article's blocks. Logic, ordering, and variable names are unchanged.🤖 Generated with Claude Code