Skip to main content


I made a thing that makes working with #CSV files in #AWK easier. It's a quick and dirty hack, but maybe it'll be useful to someone else.

git.fingerprintsoftware.ca/jla…

#awk #CSV
in reply to Jonathan Lamothe

Also, do lists in #Python seriously not have a .map function?

Edit: Ohhh... I expected it to be a method on the list object itself.

Tech Cyborg reshared this.

in reply to Jonathan Lamothe

geeksforgeeks.org/python-map-f…
in reply to Darcy Casselman

(I'm not claiming this is awesome, but it's basically the thing...)
in reply to Darcy Casselman

@flyingsquirrel Yup. And there's a multiprocessing version which can be useful if you're doing a very large csv but you probably want imap() for that one.

docs.python.org/3/library/mult…

in reply to Jonathan Lamothe

If you're looking for a function that applies another function to each element of a list and aggregates the results, it'd typically be done with a list comprehension:

[your_function(item) for item in your_list]

But you can also use list(map(your_function, your_list)) if you want. Basically, it's a built-in function rather than a method of the list class.

There's also a whole discussion to be had about lists vs generators and why you often wouldn't even need to make a list in the first place, but I won't get into that unless you want to know more.

#Python

in reply to Jonathan Lamothe

the logic being that `map()` take any iterable, jot only lists, but sets, dicts, and anything that complies with the iterable protocol. I'm not saying you have to _like_ it. See also `str.join()`.
in reply to Marcos Dione

@Marcos Dione Yeah, in hindsight, that makes sense. I'm usually a Haskell programmer, not a Python programmer, so I don't usually have to deal with the question of whether a function is on an object or not.
in reply to Jonathan Lamothe

I understand. I get similar issues when I jump to other languages. The ones I had more impedance has been golang for certain decisions and rust because of the "harsh" syntax and verboseness.

This website uses cookies. If you continue browsing this website, you agree to the usage of cookies.