@@ -7,7 +7,7 @@ short_help = "Convert yaml to json"
77
88[[command .stage ]]
99command = " stack"
10- options = {code =" yaml.safe_load ! json.dumps" }
10+ params = {code =" yaml.safe_load ! json.dumps" }
1111
1212[[command .test ]]
1313invocation = [" yml2json" ]
@@ -31,7 +31,7 @@ help = """Pull data out of xml documents using xpath."""
3131[[command .stage ]]
3232
3333command = " stack"
34- options = {code =" x.encode() ! io.BytesIO ! lxml.etree.parse ! x.findall(query) ! map(lambda y: y, x) ! list" }
34+ params = {code =" x.encode() ! io.BytesIO ! lxml.etree.parse ! x.findall(query) ! map(lambda y: y, x) ! list" }
3535
3636[[command .stage ]]
3737command =" chain"
@@ -63,26 +63,26 @@ inject_values=["pairs"]
6363
6464[[command .stage ]]
6565command = " eval"
66- options = {code =" pairs" }
66+ params = {code =" pairs" }
6767
6868[[command .stage ]]
6969command = " map"
70- options = {code =" shlex.split(x, posix=False)" }
70+ params = {code =" shlex.split(x, posix=False)" }
7171
7272[[command .stage ]]
7373command = " chain"
7474
7575[[command .stage ]]
7676command = " map"
77- options = {code =" x.partition('=') ! [x[0], ast.literal_eval(re.sub(r'^(?P<value>[A-Za-z]+)$', r'\"\\ g<value>\" ', x[2]))]" }
77+ params = {code =" x.partition('=') ! [x[0], ast.literal_eval(re.sub(r'^(?P<value>[A-Za-z]+)$', r'\"\\ g<value>\" ', x[2]))]" }
7878
7979[[command .stage ]]
8080command = " apply"
81- options = {"code" =" dict" }
81+ params = {"code" =" dict" }
8282
8383[[command .stage ]]
8484command = " map"
85- options = {code =" json.dumps" }
85+ params = {code =" json.dumps" }
8686
8787
8888[[command .test ]]
@@ -100,7 +100,7 @@ section ="Read"
100100
101101command = " map"
102102
103- options = {code =" json.loads" }
103+ params = {code =" json.loads" }
104104
105105[[command .test ]]
106106invocation = [" read-jsonl" ]
@@ -110,6 +110,33 @@ output = """{'name': 'Alice', 'age': '21'}\n{'name': 'Bob', 'age': '22'}\n"""
110110
111111[[command ]]
112112name = " read-csv"
113+ help = """
114+
115+ Read a csv file into Python dicts. Given a csv like this:
116+
117+
118+ .. code-block::
119+
120+ name,age
121+ Alice,21
122+ Bob,25
123+
124+ try:
125+
126+ .. code-block:: bash
127+
128+ $ mario read-csv <<EOF
129+ name,age
130+ Alice,21
131+ Bob,25
132+ EOF
133+ {'name': 'Alice', 'age': '21'}
134+ {'name': 'Bob', 'age': '25'}
135+
136+
137+ Specify the ``--delimiter=`` or ``--no-header`` options as needed.
138+
139+ """
113140short_help = " Load csv rows into python objects"
114141inject_values =[" delimiter" , " header" ]
115142section =" Read"
@@ -126,14 +153,14 @@ help = "Treat the first row as a header?"
126153
127154[[command .stage ]]
128155command = " apply"
129- options = {code =" mario_addons.plugins.addons.read_csv(x, header=header)" }
156+ params = {code =" mario_addons.plugins.addons.read_csv(x, header=header)" }
130157
131158[[command .stage ]]
132159command = " chain"
133160
134161[[command .stage ]]
135162command = " map"
136- options = {code =" dict(x)" }
163+ params = {code =" dict(x)" }
137164
138165[[command .test ]]
139166invocation = [" read-csv" ]
@@ -148,7 +175,7 @@ section = "Read"
148175
149176[[command .stage ]]
150177command = " stack"
151- options = {code =" yaml.safe_load" }
178+ params = {code =" yaml.safe_load" }
152179
153180[[command .test ]]
154181invocation = [" read-yaml" ]
@@ -162,7 +189,7 @@ section = "Write"
162189
163190[[command .stage ]]
164191command = " apply"
165- options ={code =" json.dumps" }
192+ params ={code =" json.dumps" }
166193
167194[[command .test ]]
168195invocation = [" stack" , " str.split" , " write-json" ]
@@ -177,7 +204,7 @@ section = "Write"
177204
178205[[command .stage ]]
179206command = " map"
180- options ={code =" toml.dumps" }
207+ params ={code =" toml.dumps" }
181208
182209[[command .test ]]
183210invocation = [" stack" , " json.loads" , " write-toml" ]
0 commit comments