You got your hands on some data that was leaked from a social network and you want to help the poor people.
Luckily you know a government service to automatically block a list of credit cards.
The service is a little old school though and you have to upload a CSV file in the exact format. The upload fails if the CSV file contains invalid data.
The CSV files should have two columns, Name and Credit Card. Also, it must be named after the following pattern:
YYYYMMDD.csv.
The leaked data doesn't have credit card details for every user and you need to pick only the affected users.
The data was published here:
You don't have much time to act.
What tools would you use to get the data, format it correctly and save it in the CSV file?
Do you have a crazy vim configuration that allows you to do all of this inside your editor? Are you a shell power user and write this as a one-liner? How would you solve this in your favorite programming language?
Show me your solution in the comments below!
Thank you all for participating!
I never thought so many people might be willing to submit a solution. This is exactly the overview about different technologies and ways of thinking I anticipated to get.
We have solutions without any coding, solutions in one line of code and solutions with over a hundred lines.
I hope everyone else also learned something new by looking at this different styles!
Make sure to also checkout the solutions on Hackernews, Reddit (and /r/haskell) and dev.to!
Cheers, Jorin

Haskell, using maps instead of structured records (to be more analogous to the original Ruby solution):
{-# LANGUAGE OverloadedLists #-} {-# LANGUAGE OverloadedStrings #-} import Control.Lens (view) import Data.Aeson (decode) import Data.ByteString (ByteString) import qualified Data.ByteString.Lazy as Bytes import Data.Map (Map) import qualified Data.Map as Map import Data.Csv (encodeByName) import Data.Text (Text) import Data.Text.Encoding (encodeUtf8) import Data.Time (getCurrentTime, formatTime) import Network.Wreq (get, responseBody) import System.Locale (defaultTimeLocale) uri = "https://gist.githubusercontent.com/jorin-vogel/7f19ce95a9a842956358/raw/e319340c2f6691f9cc8d8cc57ed532b5093e3619/data.json" main = do -- Download and decode JSON from the given URI response <- get uri let Just records = decode (view responseBody response) -- CSV library only accepts bytes for headers, not text let toUtf8 :: [Map Text (Maybe Text)] -> [Map ByteString (Maybe Text)] toUtf8 = map (Map.mapKeys encodeUtf8) -- CSV-encode the result and write out to a timestamped file time <- getCurrentTime let file = formatTime defaultTimeLocale "%Y%m%d.csv" time Bytes.writeFile file (encodeByName ["name", "creditcard"] (toUtf8 records))Also, this actually downloads from a URI instead of reading from a local file.