arp242 / uni

Query the Unicode database from the commandline, with good support for emojis
MIT License
802 stars 19 forks source link

Add csv to printing format (-as flag) #34

Closed esdnm closed 1 year ago

arp242 commented 2 years ago

I have no use for this myself, and unlikely to work on it, but I'll review and merge patches. It shouldn't actually be too hard to add.

gedw99 commented 2 years ago

Its not a bad idea for people ppes things through.

arp242 commented 2 years ago

That's what the -as json (or -json) flag is for, and to further process it with jq.

You actually can do CSV already, kind of, with the -format flag:

[~]% uni print 70 -c -format '%(char),%(cpoint),%(hex)'
p,U+0070,70

Although this isn't perfect as it won't do escaping of ,, which a dedicated CSV encoder would. But if you want to use it in a pipe with cut or awk or whatnot then that will break too, and you'll need CSV-aware tool. Using tabs or NUL bytes would be better. But again, all of this is what the JSON output is for.

Now, if someone feels CSV is useful then I'm not going to stand in their way if they want to add it, it's just that for me, personally, I don't really see the point, and have no use for it.

arp242 commented 1 year ago

Like I said, if someone really wants it then they can send a patch, and I'll merge it as long as it has a test or two and isn't absolutely horrible. But I don't really see the point of working on this as JSON and regular -format already seems to cover this, so no need to keep this "TODO item" open.