I am currently learning SQL/Python, I often just wanted to know the headers and how many rows are in a CSV file, so I just wrote a small Python script for it. import csv import readline readline.set_completer_delims(' \t\n=') readline.parse_and_bind("tab: complete") def csvOpen(file): with open(file, "r", newline='', encoding='utf-8-sig') as csvfile: reader = csv.reader(csvfile) i = next(reader) dRows = sum(1 for lin…
This can be done using two lines of Bash - `head -n 1 ` to get headers - `wc -l ` to count number of rows
Ask HN: Tools you have made for yourself?
341–350 of 458 posts
Re: Ask HN: Tools you have made for yourself?
#342I am currently learning SQL/Python, I often just wanted to know the headers and how many rows are in a CSV file, so I just wrote a small Python script for it. import csv import readline readline.set_completer_delims(' \t\n=') readline.parse_and_bind("tab: complete") def csvOpen(file): with open(file, "r", newline='', encoding='utf-8-sig') as csvfile: reader = csv.reader(csvfile) i = next(reader) dRows = sum(1 for lin…
what does sq in sqhead mean?
Re: Ask HN: Tools you have made for yourself?
#343This isn’t anywhere near as impressive as some of the examples here, but anyway: I run an Etsy store that sells artwork. One of the most time-consuming tasks was creating the mock-ups for product listings, so I wrote a shell script that used Imagemagick to automatically generate all the images. I was pretty pleased as I’d never written a Bash script before and it saves hours and hours of work. I also wrote a Ruby scr…
Re: Ask HN: Tools you have made for yourself?
#344It seems like a toy compared to most of the other tools in this thread, but FWIW I have a little script I call "did": grep "$1" ~/.bash_history | tail It just shows me the last ten commands that include a search term. E.g. "did foo" shows the last ten commands that include "foo".
This is going straight into my bash_aliases. Thanks!
Re: Ask HN: Tools you have made for yourself?
#345Re: Ask HN: Tools you have made for yourself?
#346Re: Ask HN: Tools you have made for yourself?
#347It wasn't usually very reassuring, but it felt better to see a number than just go in blind.
Re: Ask HN: Tools you have made for yourself?
#348Re: Ask HN: Tools you have made for yourself?
#349I wrote an in-terminal histogram tool[0] because... that's when/where I always need histograms. [0] https://github.com/wizzat/distribution
This is the best thing since sliced bread, but it doesn't work for me on a recent Ubuntu. Tried with both Python 2 and 3. Compare: $ sudo du -sb /etc/* | sort | uniq | sort -rn | head -10 2897355 /etc/brltty 436966 /etc/java-11-openjdk 402728 /etc/ssl 251196 /etc/apparmor.d 244732 /etc/ImageMagick-6 219185 /etc/X11 170093 /etc/fonts 144084 /etc/java-8-openjdk 131407 /etc/init.d 117524 /etc/systemd With: $ sudo du -sb…
https://jsvine.github.io/intro-to-visidata/basics/summarizin...
Re: Ask HN: Tools you have made for yourself?
#350I created bunch of scripts that allows me to spin up a full 3 node mongo server with interfaces and webui. Creates daemons to monitor everything and restart when crashing, auto-renews certificate for lets-encypt and spins up a json server with basic crud apis ... starting a new project takes 30 mins but it saves me sooo much time debugging why things are not coming up as i wanted