{"data":{"id":93,"slug":"exporting-scraped-data-to-csv-part-5-93","title":"Exporting scraped data to CSV, part 5","excerpt":"Part 5 looks at what changes when the same technique has to run every day in production. CSV is the lingua franca of spreadsheets and the most common way scraped data leaves a project. It is also…","seriesName":"Exporting scraped data to CSV","seriesPart":5,"sections":[{"heading":"Introduction","paragraphs":["Part 5 looks at what changes when the same technique has to run every day in production. 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."]},{"heading":"Putting it into practice","paragraphs":["Keep configuration such as base URLs, delays and selectors out of your code. Changing a delay should not require a redeploy.","Treat HTTP 429 responses as a signal, not an obstacle. Read the Retry-After header, back off, and resume at a slower pace.","Validate the data you extract. Prices without currencies, dates without time zones and empty fields are common sources of silent errors downstream."]},{"heading":"Step by step","paragraphs":["Pagination comes in several shapes: numbered pages, next links, offsets and opaque cursors. Each has trade-offs, and a robust scraper should detect the end of the result set rather than assuming a fixed number of pages.","Write small, focused tests for your parsers using saved HTML fixtures. They run in milliseconds and catch layout changes long before a full crawl would.","Time zones matter more than they seem. Store timestamps in UTC and convert only when displaying them."]},{"heading":"Key takeaway","paragraphs":["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."]}],"authorId":11,"authorName":"Oliver Kim","authorSlug":"oliver-kim","category":"Data Engineering","tags":["selenium","javascript"],"publishedAt":"2024-01-23T00:00:00.000Z","wordCount":213,"readingTimeMinutes":2}}