csvquote: https://github.com/dbro/csvquote
Especially for use with existing shell text processing tools, eg. cut, sort, wc, etc.
33 karma · joined July 13, 2010
csvquote: https://github.com/dbro/csvquote
Especially for use with existing shell text processing tools, eg. cut, sort, wc, etc.
<https://github.com/dbro/csvquote>
Using it with the first example command from this article would be
csvquote file.csv | awk -F, '{print $1}' | csvquote -u
By using the "-u" flag in the last step of the pipeline, all of the problematic quoted delimiters get restored.In principle:
cat textfile.csv | csvquote | awk -f myprogram.awk | csvquote -u > output.csv
Also works for other text processing tools like cut, sed, sort, etc.It is handy for pipelining UNIX commands so that they can handle data that includes commas and newlines inside fields. In this example, csvquote is used twice in the pipeline, first at the beginning to make the transformation to ASCII separators and then at the end to undo the transformation so that the separators are human-readable.
> csvquote foobar.csv | cut -d ',' -f 5 | sort | uniq -c | csvquote -u
It doesn't yet have any built-in awareness of UTF or multi-byte characters, but I'd be happy to receive a pull request if it's something you're able to offer.
Instead of using a separate set of tools to work with CSV data, use an adapter to allow existing tools to work around CSV's quirky quoting methods.
csvquote (https://github.com/dbro/csvquote) enables the regular UNIX command line text toolset (like cut, wc, awk, etc.) to work properly with CSV data.
https://github.com/dbro/csvquote
csvquote allows UNIX tools to work properly with quoted fields that contain delimiters inside the data. It is a simple translation tool that temporarily replaces the special characters occurring inside quotes with harmless non-printing characters. You do it as a first step in the pipeline, then do the regular operations using UNIX tools, and the last step of of the pipeline restores those troublesome characters back inside the data fields.
So instead of making a more complex version of tools like grep, we can make the data simple for these tools to understand. That's what https://github.com/dbro/csvquote does. It can be run in a pipeline before the grep stage, and allow grep/cut/awk/... to work with unambiguous field and record delimiters. Then it can restore the newlines and commas inside the quoted fields at the end of the pipeline.
https://github.com/dbro/csvquote is a small and fast script that can replace ambiguous separators (commas and newlines, for example) inside quoted fields, so that other text tools can work with a simple grammar. After that work is done, the ambiguous commas inside quoted fields get restored. I wrote it to use unix shell tools like cut, awk, ... with CSV files containing millions of records.
... but I wouldn't claim that it's done efficiently. From the comments in the code's tests:
# some results based on running speed tests on a lightweight netbook:
# standard error = 0.01, 10kb of registers
# < 1 ms per init()
# < 1 ms per update()
# < 1 ms per count() for single set
# ~30 ms per set for count() of union of setsIt is indeed a simple state machine (see https://github.com/dbro/csvquote/blob/master/csvquote.c), and it translates CSV/TSV files into files which follow the spirit of what's described in the original article in this thread.
But instead of using control characters as separators, it uses them INSIDE the quoted fields. This makes it easy to work with the standard UNIX text manipulation tools, which expect tabs and newlines to be the field and record separators.
The motivation for writing the tool was to work with CSV files (usually from Excel) that were hundreds of megabytes. These files came from outside my organization, and often from nontechnical people - so it would have been difficult to get them into a more convenient format. That's the killer feature of the CSV/TSV format: it's readable by the large number of nontechnical information workers, in almost every application they use. I can't think of a file format that is more widely recognized (even if it's not always consistently defined in practice).
Beyond the shameless self-promotion I found that getting people to use it would take a lot of work, with lots of alternatives out there that have dedicated teams promoting them. On the positive side, I learned a lot from it; but I never made any significant money from it. If you're comfortable sharing your next steps, I'd be interested to know what you're aiming for with this project.
Good luck!
There are less expensive alternatives to Linode. I switched to Loose Foot Computing (http://www.lfcvps.com) about a year ago and their service has been great. They often have promotional deals listed on lowendbox. See http://www.lowendbox.com/?s=loose+foot&searchsubmit=Find
tmux is amazing and takes care of window management. No need for dwm or xmonad anymore.
Lastpass integration with the browser works great with Chrome OS. This replaced keypassx for me.
USB tethering with my android phone "just works" to get on the internet.
Really happy so far. This is the right mix of easy, fast, cheap, and secure for me.
http://www.aliexpress.com/product-fm/546571245-Mele-A2000-TV...
I just received one and installed Debian squeeze on it, following the instructions here http://rhombus-tech.net/allwinner_a10/hacking_the_mele_a1000...
Shipping took about a month, but now that it's here it's as good as I expected.
>muss elvis [queues up all songs that have "elvis" in the artist, album, or track name]
>muss elv pres not jailhouse
>muss lion rich -a -r ["Hello, is it me you're looking for?"]
-a means append to existing playlist, -r means randomize the playlist
>muss
when no arguments are provided, it opens up a very fast search/filter/browse interface using dmenu
Inspiration for this project were plait and the then-new instant search on Google.
I built this domain name suggestion tool that does both of these instantly: http://domainjig.com
In case you're wondering, it absolutely DOES NOT hijack or steal your ideas and register your domain name behind your back.
some support for filtering and grouping
250MB data size limit
nice mapping capabilities
The expired domain search is cool, well done with this tool.
Make it faster. Right now, loading the page to search for availability is taking longer than 10 seconds. When searching using the different tools, the response comes back after a few seconds delay. If you're comfortable discussing it, what are the major components of the backend? Is your data stored in RAM? Can you make the availability check instant?
eg. the expired domain search for "rabbit" over the last 30 days took a few minutes to return 2 pages of results. maybe the traffic referred from this post on HN is finding some bottlenecks for you?
The name spinner came up with some interesting suggestions. I'd suggest removing or hiding some of the advanced options, in favor of simplifying the default interface.
Hope that helps.
Frustrated by what was available, I created a weather app for Android which did what I want from a weather app: smart alerts about tomorrow's weather. In talking with people about it, I learned there are many different ideas about how the perfect weather app would behave for different people. This is not surprising; weather information is only useful in the context of how it would change your behavior. Since everyone has a different schedule, a consistent and simple interface is not likely to be possible.
The name of the app I created is "Anticipates (Weather)". comments are welcome!
Just as important is the back-channel that allows comments to be created and shown in different places (this was mentioned as an "incidental" note in Tech Crunch's article describing the comments system http://techcrunch.com/2011/03/01/facebook-rolls-out-overhaul...). I find it particularly appropriate to bring this up here on HN because I expect Tech Crunch to look with envy or exasperation when comments are posted HERE (HN) about stories appearing THERE (TC). Why shouldn't TC want to have all of the relevant, useful comments appear next to the content they create and host? Facebook comments could help that happen (indeed, so could have disqus if it were used by HN and TC both. Alas, disqus, RIP).