<?xml version="1.0" encoding="UTF-8"?>
<response><data><post><id>193</id><slug>exporting-scraped-data-to-csv-part-10-193</slug><title>Exporting scraped data to CSV, part 10</title><excerpt>For part 10, we revisit the basics with a fresh example and a few lessons learned the hard way. CSV is the lingua franca of spreadsheets and the most common way scraped data leaves a project. It is…</excerpt><seriesName>Exporting scraped data to CSV</seriesName><seriesPart>10</seriesPart><sections><item><heading>Introduction</heading><paragraphs><item>For part 10, we revisit the basics with a fresh example and a few lessons learned the hard way. CSV is the lingua franca of spreadsheets and the most common way scraped data leaves a project. It is also surprisingly easy to produce a CSV that opens incorrectly.</item></paragraphs></item><item><heading>What to watch for</heading><paragraphs><item>Keep configuration such as base URLs, delays and selectors out of your code. Changing a delay should not require a redeploy.</item><item>Log every request with its URL, status code and duration. When something goes wrong at two in the morning, those logs are the difference between a quick fix and a long investigation.</item></paragraphs></item><item><heading>Going further</heading><paragraphs><item>Time zones matter more than they seem. Store timestamps in UTC and convert only when displaying them.</item><item>Store raw responses alongside parsed output while you are developing. When a parser breaks, you can replay the saved HTML instead of hitting the site again.</item></paragraphs></item><item><heading>Key takeaway</heading><paragraphs><item>Use a proper CSV writer rather than joining strings, quote fields that contain commas or newlines, write UTF-8, and keep dates in ISO 8601.</item></paragraphs></item></sections><authorId>9</authorId><authorName>Mateo Hughes</authorName><authorSlug>mateo-hughes</authorSlug><category>Data Engineering</category><tags><item>http</item></tags><publishedAt>2024-11-10T00:00:00.000Z</publishedAt><wordCount>168</wordCount><readingTimeMinutes>2</readingTimeMinutes></post></data></response>
