4 ms·
Your CSV peeking epiphany was in essence a matter of code vs. tools though rather than necessarily CLI vs. GUI. On Windows you might just as well have discovere
by hanoz 12y ago
Your CSV peeking epiphany was in essence a matter of code vs. tools though rather than necessarily CLI vs. GUI. On Windows you might just as well have discovered you could fire up Linqpad and enter File.ReadLines("massive.csv").First() for example.
- Someone 12y agoRunning a shell in a GUI doesn't make it lose its "I am a CLI" property. That is a CLI.
- eropple 12y agoI disagree. It's a REPL, but a REPL is not always a CLI. (Frankly, most REPLs are smarter than shells. I go to irb way more than I do bash, these days.)
- hueving 12y agoDo you not see the horrific syntax of what you just suggested as simple?
- mc808 12y agoIt's pretty clear what it does. It's also C#, so building up to a less trivial task will be much less horrific than find . -type f -name '*.pgn' -print0 | xargs -0 -n4 -P4 mawk '/Result/ { split($0, a, "-"); res = substr(a[1], length(a[1]), 1); if (res == 1) white++; if (res == 0) black++; if (res == 2) draw++ } END { print white+black+draw, white, black, draw }' | mawk '{games += $1; white += $2; black += $3; draw += $4; } END { print games, white, black, draw }'
- kevin_thibedeau 12y agoIn a real production environment that command line would be put into a script parametrized with named variables and the embedded awk scripts would be changed to here-docs.
- peterhunt 12y agoAre you arguing that shell scripts scale to larger applications better than C#?
- mc808 12y agoSounds good although at that point it's just programming, and there are tools that are cleaner and faster and more robust than piping semi-structured strings around from a command line. The one real benefit that can be argued is ubiquity (on *ix). Not every system has Perl, Python, or Ruby installed - or Hadoop for that matter - but there's usually a programmable shell and some variant of the standard utilities that will get something done in a pinch. If it happens to be 200x faster than some enormous framework, so much the better.
- TylerE 12y agoOr just use vim or any other editor smart enough not to try to slurp the whole file in one go.
- eru 12y agoActually, mmapping the file should Just Work (tm)?
- alrs 12y agoThe example was a multi-gigabyte CSV file. You just sucked the whole thing off the disk into RAM so that you could shave off the first line. If you're unlucky, you started swapping out to disk about halfway through.
- chrishynes 12y agoWrong. ReadLines returns an IEnumerable<string> and lets you read line by line without loading the entire file into memory: http://msdn.microsoft.com/en-us/library/dd383503%28v=vs.110%29.aspx http://msdn.microsoft.com/en-us/library/dd383503%28v=vs.110%....
- recursive 12y agoThat code you're replying about was carefully and correctly written. You just replied as if you know how it works just so you could look like you know what you're talking about. If you're unlucky, someone who actually knows how File.ReadLines() works will show up in an hour or two and explain that it's lazily evaluated.
- alrs 12y ago:) touche