Skip to content

Releases: ryuichiueda/opy

v2.6.2

03 Jul 00:47
Compare
Choose a tag to compare

This version gets the feature for handling xlsx files.

### T["sheet name"] is a DataFrame object of Pandas ###
$ opy -t xlsx '{a = T["Sheet1"].values};[a]' ./testdata/test.xlsx
[[123 datetime.datetime(2021, 1, 1, 0, 0) nan]
 ['危険シェル芸' 'ドラゴン曲線' nan]
 ['キュアエンジニア' '素数' nan]
 ['エ"ク"シ"ェ"ル"芸' '変,態,シ,ェ,ル,芸' nan]
 [1 2 3.0]
 [nan nan nan]]
$ opy -t xlsx '[T["Sheet1"][0][0]]' ./testdata/test.xlsx 
123

v2.6.0

02 Jul 04:33
Compare
Choose a tag to compare

-t csv option is added to this version. This option makes opy reads a CSV file entirely. The CSV data is stored to the default dictionary T. Followings are example.

### read a csv data and print the dictionary ### 
$ echo -e 'a,b,c\nd,e,f'
a,b,c
d,e,f
$ echo -e 'a,b,c\nd,e,f' | opy -t csv '[T]'
{0: ['a', 'b', 'c'], 1: ['d', 'e', 'f']}
### print an element ###
$ echo -e 'a,b,c\nd,e,f' | opy -t csv '[T[1][1]]' 
e

The csv module can handle an element that contains newline charactes.

$ echo -e 'a,b,"c\nd",e,f'
a,b,"c                             <- this is **one-line** csv data ( "c\nd" is an element.) 
d",e,f
$ echo -e 'a,b,"c\nd",e,f' | opy -t csv '[T[0][2]]'
c
d

v2.5.2

07 Feb 02:37
Compare
Choose a tag to compare

The version number if fixed.

v2.5.1

03 Jan 14:38
Compare
Choose a tag to compare

With an option -t <json/yaml/xml>, opy reads contents of a file as json/yaml/xml data and sets it to an object "T".

examples:

$ echo '{"hoge":["a","b"]}' | opy -t json '[*T["hoge"]]'
a
b
$ echo -e 'aho:\n  boke: ["a","b"]' | opy -t yaml '[*T["aho"]["boke"]]'
a
b
$ echo -e '<?xml version="1.0" encoding="utf-8"?>\n<foo>bar</foo>' | opy -t xml '[e.text for e in T.iter("foo")]'
bar

v2.3.1

16 Jul 00:46
Compare
Choose a tag to compare

In this version, the indifference to PIPEFAIL is intensified.

  • version 2.3.0
$ yes aho | opy '[F1]' | head
aho
aho
aho
aho
aho
aho
aho
aho
aho
aho
Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>
BrokenPipeError: [Errno 32] Broken pipe
$ echo ${PIPESTATUS[@]}
141 120 0
  • this version
$ yes aho | opy '[F1]' | head
aho
aho
aho
aho
aho
aho
aho
aho
aho
aho
$ echo ${PIPESTATUS[@]}
141 0 0 

v2.3.0

30 Dec 08:55
Compare
Choose a tag to compare

This version has a dictionary of litst, which is named K. K is useful when we want to store values for each key.

### example data###
$ cat data 
a 100
b 2
a 10
b -1
a 10000
### output values as a list for each key ###
$ cat data | opy '{K[F1].append(F2)};E:{p_(K)}'
a [100, 10, 10000]
b [2, -1]
### output the maximum value for every key ###
$ cat data | opy '{K[F1].append(F2)};E:{x={k:max(K[k]) for k in K}};E:{p_(x)}'
a 10000
b 2

v2.2.2

06 Nov 08:48
Compare
Choose a tag to compare
  • supported combined options like -sc
  • implemented CSV output mode (-C option)
$ echo '1,2,3' | opy -cC '[F1,F3]'   # -c: CSV input, -C: CSV output
"1","3"

v2.2.0

03 Nov 01:48
Compare
Choose a tag to compare
  • implemented csv mode
$ cat data.csv 
1,2,3
"a","b"",","c"
"dd,""fg"",de","dd,""fg"",de",","
"hc,"",","bd,"",d"
$ cat data.csv | opy -c -o '|' '[*F[1:]]' #separate each value with "|"
1|2|3
a|b",|c
dd,"fg",de|dd,"fg",de|,
hc,",|bd,",d

v2.1.3

01 Nov 08:43
Compare
Choose a tag to compare
  • support of null string for input field separator
$ echo abc | opy -i '' '[F2]'
b
  • make variables read by -v option keep as strings when -s is given
$ echo abc | opy -s -v a=123 '[a*2]'
123123

v.2.1.1

27 Oct 07:42
Compare
Choose a tag to compare
  • add -v option
$ a=3.14
$ b="abc def " 
$ opy -v "x=$a" -v "y=$b" 'B:[x*2, y*2]' 
6.28 abc def abc def