archiecobbs / csvprintf Goto Github PK
View Code? Open in Web Editor NEWSimple CSV file parser for the UNIX command line
License: Apache License 2.0
Simple CSV file parser for the UNIX command line
License: Apache License 2.0
I think it would be useful if there was a group option. You would specify a special group printf statement, and csvprintf would print this every time the group changes.
Example: given the input.csv
:
Name,City,Email
Fred,New York,[email protected]
Lilly,New York,[email protected]
No Body,Cyberspace,[email protected]
And this will print a grouped list in MarkDown:
$ cat input.csv | csvprintf -ig '\n# %2$s\n' '- [%1$s](mailto:%3$s)\n'
# New York
- [Fred](mailto:[email protected])
- [Lilly](mailto:[email protected])
# Cyberspace
- [No Boddy](mailto:[email protected])
The CSV is expected to be sorted. Also, with -G
a group footer can be specified. And optionally, with -g1
an additional level of grouping can be specified (a number is necessary, because per level, only a group header or footer needs to be specified). Also, this option would work nice with the XML option.
I thought up this option, because I wanted some kind of grouped output of a list of awesome CSV tools a friend of mine maintains, but awk
wasn't up to the task...
Please support convert input to json
Trying to build this in Cygwin on windows, iconv (devel) is certainly installed:
$ ./autogen.sh
cleaning up
running aclocal
running autoheader
running automake
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/${ <-- HERE ([^ \t=:+{}]+)}/ at /usr/bin/automake-1.14 line 3930.
configure.ac:41: installing 'scripts/compile'
configure.ac:21: installing 'scripts/install-sh'
configure.ac:21: installing 'scripts/missing'
Makefile.am: installing 'scripts/depcomp'
running autoconf
/cygdrive/d/logs/ad/csvprintf-master
$ ./configure
configure: loading site script /usr/share/config.site
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make sets $(MAKE)... (cached) yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.exe
checking for suffix of executables... .exe
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking for printf... /usr/bin/printf
checking for xsltproc... /usr/bin/xsltproc
checking for iconv_open in -lc... no
configure: error: required function iconv_open missing
/cygdrive/d/logs/ad/csvprintf-master
$ which iconv
/usr/bin/iconv
I found an old "fork" that used cygport to help with compiling I assume, the patch doesn't seem to work for me when I applied the changes directly to configure.ac.
https://github.com/fd00/yacp/blob/master/csvprintf/csvprintf-1.0.3-1bl1.src.patch
Consider your csv example, could you add an option '-u 1' that uses the first line of the csv as naming scheme for the xml output column names?
So for example the following output would happen
$ cat input.csv | csvprintf -ix -u 1
<?xml version="1.0" encoding="ISO-8859-1"?>
<csv>
<row>
<NAME>Fred Smith</NAME>
<ADDRESS>1234 Main St.
Anytown, USA 39103</ADDRESS>
<POINTS>123.4567</POINTS>
</row>
<row>
<NAME>Wayne "The Great One" Gretsky</NAME>
<ADDRESS>59 Hockey Lane</ADDRESS>
<POINTS>999999</POINTS>
</row>
</csv>
thanks a lot
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.