84

If you care about performance, you may want to avoid CSV files. But since our data sources are often like our family, we can't make a choice, we'll see in this blog post how to process a CSV file as fast as possible.

all 7 comments
sorted by: hot top new old
[-] fartsparkles@sh.itjust.works 27 points 2 years ago

Holy shit, switching to PyArrow is going to make me seem a mystical wizard when I merge in the morning. I’ve easily halved the execution time of a horrible but unavoidable job (yay crappy vendor “API” that returns a huge CSV).

[-] AlecSadler@sh.itjust.works 3 points 2 years ago

You and me both. I've been parsing around 10-100 million row CSVs lately and...this will hopefully help.

[-] SpaceNoodle@lemmy.world 7 points 2 years ago

LOL just use fscanf() you silly goose

[-] stevedidwhat_infosec@infosec.pub 4 points 2 years ago* (last edited 2 years ago)

Okay so would it be faster to convert it to something better and then do something faster with this better format?

Edit: I guess looking at the numbers, they’re already pretty low there. Idk how much faster it’d really be and whether not it’d be worth doing

What’s even the “gold standard” for logging stuff I guess?

[-] sugar_in_your_tea@sh.itjust.works 2 points 2 years ago

That really depends on how much of it you're doing. If you're just handing a few times at a time, the difference between 0.1s and 3s isn't that big of a deal. If you're handling thousands or even millions in a day, it can be an order of magnitude cost savings to make it more efficient.

We use a CSVs at work, but it's not a common thing so we just use the built-in csv library. If we did more with it, pandas would be the way to go (or maybe we'd rewrite that service in Rust).

this post was submitted on 18 Mar 2024
84 points (100.0% liked)

Python

8022 readers
2 users here now

Welcome to the Python community on the programming.dev Lemmy instance!

📅 Events

PastNovember 2023

October 2023

July 2023

August 2023

September 2023

🐍 Python project:
💓 Python Community:
✨ Python Ecosystem:
🌌 Fediverse
Communities
Projects
Feeds

founded 3 years ago
MODERATORS