mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2026-06-19 22:28:17 +02:00
doc update
This commit is contained in:
@@ -123,7 +123,6 @@ pip3 install jc
|
||||
| FreeBSD | `portsnap fetch update && cd /usr/ports/textproc/py-jc && make install clean` |
|
||||
| Ansible filter plugin | `ansible-galaxy collection install community.general` |
|
||||
| FortiSOAR connector | Install from FortiSOAR Connector Marketplace |
|
||||
| Mise-en-place (Linux/MacOS) | `mise use -g jc@latest` |
|
||||
|
||||
> For more OS Packages, see https://repology.org/project/jc/versions.
|
||||
|
||||
@@ -178,8 +177,9 @@ option.
|
||||
| `--crontab` | `crontab` command and file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/crontab) |
|
||||
| `--crontab-u` | `crontab` file parser with user support | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/crontab_u) |
|
||||
| `--csv` | CSV file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/csv) |
|
||||
| `--csv-s` | CSV file streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/csv_s) |
|
||||
| `--csv-ih` | CSV implicit header file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/csv_ih) |
|
||||
| `--csv-s` | CSV file streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/csv_s) |
|
||||
| `--csv-ih-s` | CSV implicit header file streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/csv_ih_s) |
|
||||
| `--curl-head` | `curl --head` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/curl_head) |
|
||||
| `--date` | `date` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/date) |
|
||||
| `--datetime-iso` | ISO 8601 Datetime string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/datetime_iso) |
|
||||
@@ -310,7 +310,10 @@ option.
|
||||
| `--traceroute-s` | `traceroute` and `traceroute6` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/traceroute_s) |
|
||||
| `--tsv` | TSV file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/tsv) |
|
||||
| `--tsv-ih` | TSV implicit header file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/tsv_ih) |
|
||||
| `--tsv-s` | TSV file streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/tsv_s) |
|
||||
| `--tsv-ih-s` | TSV implicit header file streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/tsv_ih_s) |
|
||||
| `--tune2fs` | `tune2fs -l` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/tune2fs) |
|
||||
| `--typeset` | `typeset` and `declare` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/typeset) |
|
||||
| `--udevadm` | `udevadm info` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/udevadm) |
|
||||
| `--ufw` | `ufw status` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ufw) |
|
||||
| `--ufw-appinfo` | `ufw app info [application]` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ufw_appinfo) |
|
||||
@@ -1387,4 +1390,4 @@ cat istio.yaml | jc -p --yaml
|
||||
]
|
||||
```
|
||||
|
||||
© 2019-2025 Kelly Brazil
|
||||
© 2019-2026 Kelly Brazil
|
||||
@@ -4,7 +4,7 @@ _jc()
|
||||
jc_about_options jc_about_mod_options jc_help_options jc_special_options
|
||||
|
||||
jc_commands=(acpi airport amixer apt-cache apt-get arp blkid bluetoothctl cbt certbot chage cksum crontab curl date debconf-show df dig dmidecode dpkg du efibootmgr env ethtool file findmnt finger free git gpg hciconfig host id ifconfig iostat ip ipconfig iptables iw iwconfig jobs last lastb ls lsattr lsb_release lsblk lsmod lsof lspci lsusb md5 md5sum mdadm mount mpstat needrestart net netstat nmcli nsd-control ntpq os-prober pacman pidstat ping ping6 pip pip3 postconf printenv ps route rpm rsync sfdisk sha1sum sha224sum sha256sum sha384sum sha512sum shasum ss ssh sshd stat sum swapon sysctl systemctl systeminfo timedatectl top tracepath tracepath6 traceroute traceroute6 tune2fs udevadm ufw uname update-alternatives upower uptime vdir veracrypt vmstat w wc wg who xrandr yay zipinfo zpool)
|
||||
jc_parsers=(--acpi --airport --airport-s --amixer --apt-cache-show --apt-get-sqq --arp --asciitable --asciitable-m --blkid --bluetoothctl --cbt --cef --cef-s --certbot --chage --cksum --clf --clf-s --crontab --crontab-u --csv --csv-s --curl-head --date --datetime-iso --debconf-show --df --dig --dir --dmidecode --dpkg-l --du --efibootmgr --email-address --env --ethtool --file --find --findmnt --finger --free --fstab --git-log --git-log-s --git-ls-remote --gpg --group --gshadow --hash --hashsum --hciconfig --history --host --hosts --http-headers --id --ifconfig --ini --ini-dup --iostat --iostat-s --ip-address --ipconfig --iptables --ip-route --iw-scan --iwconfig --jar-manifest --jobs --jwt --kv --kv-dup --last --ls --ls-s --lsattr --lsb-release --lsblk --lsmod --lsof --lspci --lsusb --m3u --mdadm --mount --mpstat --mpstat-s --needrestart --netstat --net-localgroup --net-user --nmcli --nsd-control --ntpq --openvpn --os-prober --os-release --pacman --passwd --path --path-list --pci-ids --pgpass --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --pkg-index-apk --pkg-index-deb --plist --postconf --proc --proc-buddyinfo --proc-cmdline --proc-consoles --proc-cpuinfo --proc-crypto --proc-devices --proc-diskstats --proc-filesystems --proc-interrupts --proc-iomem --proc-ioports --proc-loadavg --proc-locks --proc-meminfo --proc-modules --proc-mtrr --proc-pagetypeinfo --proc-partitions --proc-slabinfo --proc-softirqs --proc-stat --proc-swaps --proc-uptime --proc-version --proc-vmallocinfo --proc-vmstat --proc-zoneinfo --proc-driver-rtc --proc-net-arp --proc-net-dev --proc-net-dev-mcast --proc-net-if-inet6 --proc-net-igmp --proc-net-igmp6 --proc-net-ipv6-route --proc-net-netlink --proc-net-netstat --proc-net-packet --proc-net-protocols --proc-net-route --proc-net-tcp --proc-net-unix --proc-pid-fdinfo --proc-pid-io --proc-pid-maps --proc-pid-mountinfo --proc-pid-numa-maps --proc-pid-smaps --proc-pid-stat --proc-pid-statm --proc-pid-status --ps --resolve-conf --route --route-print --rpm-qi --rsync --rsync-s --semver --sfdisk --shadow --srt --ss --ssh-conf --sshd-conf --stat --stat-s --swapon --sysctl --syslog --syslog-s --syslog-bsd --syslog-bsd-s --systemctl --systemctl-lj --systemctl-ls --systemctl-luf --systeminfo --time --timedatectl --timestamp --toml --top --top-s --tracepath --traceroute --traceroute-s --tune2fs --udevadm --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --url --ver --veracrypt --vmstat --vmstat-s --w --wc --wg-show --who --x509-cert --x509-crl --x509-csr --xml --xrandr --yaml --zipinfo --zpool-iostat --zpool-status)
|
||||
jc_parsers=(--acpi --airport --airport-s --amixer --apt-cache-show --apt-get-sqq --arp --asciitable --asciitable-m --blkid --bluetoothctl --cbt --cef --cef-s --certbot --chage --cksum --clf --clf-s --crontab --crontab-u --csv --csv-ih --csv-s --csv-ih-s --curl-head --date --datetime-iso --debconf-show --df --dig --dir --dmidecode --dpkg-l --du --efibootmgr --email-address --env --ethtool --file --find --findmnt --finger --free --fstab --git-log --git-log-s --git-ls-remote --gpg --group --gshadow --hash --hashsum --hciconfig --history --host --hosts --http-headers --id --ifconfig --ini --ini-dup --iostat --iostat-s --ip-address --ipconfig --iptables --ip-route --iw-scan --iwconfig --jar-manifest --jobs --jwt --kv --kv-dup --last --ls --ls-s --lsattr --lsb-release --lsblk --lsmod --lsof --lspci --lsusb --m3u --mdadm --mount --mpstat --mpstat-s --needrestart --netstat --net-localgroup --net-user --nmcli --nsd-control --ntpq --openvpn --os-prober --os-release --pacman --passwd --path --path-list --pci-ids --pgpass --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --pkg-index-apk --pkg-index-deb --plist --postconf --proc --proc-buddyinfo --proc-cmdline --proc-consoles --proc-cpuinfo --proc-crypto --proc-devices --proc-diskstats --proc-filesystems --proc-interrupts --proc-iomem --proc-ioports --proc-loadavg --proc-locks --proc-meminfo --proc-modules --proc-mtrr --proc-pagetypeinfo --proc-partitions --proc-slabinfo --proc-softirqs --proc-stat --proc-swaps --proc-uptime --proc-version --proc-vmallocinfo --proc-vmstat --proc-zoneinfo --proc-driver-rtc --proc-net-arp --proc-net-dev --proc-net-dev-mcast --proc-net-if-inet6 --proc-net-igmp --proc-net-igmp6 --proc-net-ipv6-route --proc-net-netlink --proc-net-netstat --proc-net-packet --proc-net-protocols --proc-net-route --proc-net-tcp --proc-net-unix --proc-pid-fdinfo --proc-pid-io --proc-pid-maps --proc-pid-mountinfo --proc-pid-numa-maps --proc-pid-smaps --proc-pid-stat --proc-pid-statm --proc-pid-status --ps --resolve-conf --route --route-print --rpm-qi --rsync --rsync-s --semver --sfdisk --shadow --srt --ss --ssh-conf --sshd-conf --stat --stat-s --swapon --sysctl --syslog --syslog-s --syslog-bsd --syslog-bsd-s --systemctl --systemctl-lj --systemctl-ls --systemctl-luf --systeminfo --time --timedatectl --timestamp --toml --top --top-s --tracepath --traceroute --traceroute-s --tsv --tsv-ih --tsv-s --tsv-ih-s --tune2fs --typeset --udevadm --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --url --ver --veracrypt --vmstat --vmstat-s --w --wc --wg-show --who --x509-cert --x509-crl --x509-csr --xml --xrandr --yaml --zipinfo --zpool-iostat --zpool-status)
|
||||
jc_options=(--force-color -C --debug -d --monochrome -m --meta-out -M --pretty -p --quiet -q --raw -r --slurp -s --unbuffer -u --yaml-out -y)
|
||||
jc_about_options=(--about -a)
|
||||
jc_about_mod_options=(--pretty -p --yaml-out -y --monochrome -m --force-color -C)
|
||||
|
||||
@@ -127,7 +127,7 @@ _jc() {
|
||||
'zipinfo:run "zipinfo" command with magic syntax.'
|
||||
'zpool:run "zpool" command with magic syntax.'
|
||||
)
|
||||
jc_parsers=(--acpi --airport --airport-s --amixer --apt-cache-show --apt-get-sqq --arp --asciitable --asciitable-m --blkid --bluetoothctl --cbt --cef --cef-s --certbot --chage --cksum --clf --clf-s --crontab --crontab-u --csv --csv-s --curl-head --date --datetime-iso --debconf-show --df --dig --dir --dmidecode --dpkg-l --du --efibootmgr --email-address --env --ethtool --file --find --findmnt --finger --free --fstab --git-log --git-log-s --git-ls-remote --gpg --group --gshadow --hash --hashsum --hciconfig --history --host --hosts --http-headers --id --ifconfig --ini --ini-dup --iostat --iostat-s --ip-address --ipconfig --iptables --ip-route --iw-scan --iwconfig --jar-manifest --jobs --jwt --kv --kv-dup --last --ls --ls-s --lsattr --lsb-release --lsblk --lsmod --lsof --lspci --lsusb --m3u --mdadm --mount --mpstat --mpstat-s --needrestart --netstat --net-localgroup --net-user --nmcli --nsd-control --ntpq --openvpn --os-prober --os-release --pacman --passwd --path --path-list --pci-ids --pgpass --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --pkg-index-apk --pkg-index-deb --plist --postconf --proc --proc-buddyinfo --proc-cmdline --proc-consoles --proc-cpuinfo --proc-crypto --proc-devices --proc-diskstats --proc-filesystems --proc-interrupts --proc-iomem --proc-ioports --proc-loadavg --proc-locks --proc-meminfo --proc-modules --proc-mtrr --proc-pagetypeinfo --proc-partitions --proc-slabinfo --proc-softirqs --proc-stat --proc-swaps --proc-uptime --proc-version --proc-vmallocinfo --proc-vmstat --proc-zoneinfo --proc-driver-rtc --proc-net-arp --proc-net-dev --proc-net-dev-mcast --proc-net-if-inet6 --proc-net-igmp --proc-net-igmp6 --proc-net-ipv6-route --proc-net-netlink --proc-net-netstat --proc-net-packet --proc-net-protocols --proc-net-route --proc-net-tcp --proc-net-unix --proc-pid-fdinfo --proc-pid-io --proc-pid-maps --proc-pid-mountinfo --proc-pid-numa-maps --proc-pid-smaps --proc-pid-stat --proc-pid-statm --proc-pid-status --ps --resolve-conf --route --route-print --rpm-qi --rsync --rsync-s --semver --sfdisk --shadow --srt --ss --ssh-conf --sshd-conf --stat --stat-s --swapon --sysctl --syslog --syslog-s --syslog-bsd --syslog-bsd-s --systemctl --systemctl-lj --systemctl-ls --systemctl-luf --systeminfo --time --timedatectl --timestamp --toml --top --top-s --tracepath --traceroute --traceroute-s --tune2fs --udevadm --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --url --ver --veracrypt --vmstat --vmstat-s --w --wc --wg-show --who --x509-cert --x509-crl --x509-csr --xml --xrandr --yaml --zipinfo --zpool-iostat --zpool-status)
|
||||
jc_parsers=(--acpi --airport --airport-s --amixer --apt-cache-show --apt-get-sqq --arp --asciitable --asciitable-m --blkid --bluetoothctl --cbt --cef --cef-s --certbot --chage --cksum --clf --clf-s --crontab --crontab-u --csv --csv-ih --csv-s --csv-ih-s --curl-head --date --datetime-iso --debconf-show --df --dig --dir --dmidecode --dpkg-l --du --efibootmgr --email-address --env --ethtool --file --find --findmnt --finger --free --fstab --git-log --git-log-s --git-ls-remote --gpg --group --gshadow --hash --hashsum --hciconfig --history --host --hosts --http-headers --id --ifconfig --ini --ini-dup --iostat --iostat-s --ip-address --ipconfig --iptables --ip-route --iw-scan --iwconfig --jar-manifest --jobs --jwt --kv --kv-dup --last --ls --ls-s --lsattr --lsb-release --lsblk --lsmod --lsof --lspci --lsusb --m3u --mdadm --mount --mpstat --mpstat-s --needrestart --netstat --net-localgroup --net-user --nmcli --nsd-control --ntpq --openvpn --os-prober --os-release --pacman --passwd --path --path-list --pci-ids --pgpass --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --pkg-index-apk --pkg-index-deb --plist --postconf --proc --proc-buddyinfo --proc-cmdline --proc-consoles --proc-cpuinfo --proc-crypto --proc-devices --proc-diskstats --proc-filesystems --proc-interrupts --proc-iomem --proc-ioports --proc-loadavg --proc-locks --proc-meminfo --proc-modules --proc-mtrr --proc-pagetypeinfo --proc-partitions --proc-slabinfo --proc-softirqs --proc-stat --proc-swaps --proc-uptime --proc-version --proc-vmallocinfo --proc-vmstat --proc-zoneinfo --proc-driver-rtc --proc-net-arp --proc-net-dev --proc-net-dev-mcast --proc-net-if-inet6 --proc-net-igmp --proc-net-igmp6 --proc-net-ipv6-route --proc-net-netlink --proc-net-netstat --proc-net-packet --proc-net-protocols --proc-net-route --proc-net-tcp --proc-net-unix --proc-pid-fdinfo --proc-pid-io --proc-pid-maps --proc-pid-mountinfo --proc-pid-numa-maps --proc-pid-smaps --proc-pid-stat --proc-pid-statm --proc-pid-status --ps --resolve-conf --route --route-print --rpm-qi --rsync --rsync-s --semver --sfdisk --shadow --srt --ss --ssh-conf --sshd-conf --stat --stat-s --swapon --sysctl --syslog --syslog-s --syslog-bsd --syslog-bsd-s --systemctl --systemctl-lj --systemctl-ls --systemctl-luf --systeminfo --time --timedatectl --timestamp --toml --top --top-s --tracepath --traceroute --traceroute-s --tsv --tsv-ih --tsv-s --tsv-ih-s --tune2fs --typeset --udevadm --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --url --ver --veracrypt --vmstat --vmstat-s --w --wc --wg-show --who --x509-cert --x509-crl --x509-csr --xml --xrandr --yaml --zipinfo --zpool-iostat --zpool-status)
|
||||
jc_parsers_describe=(
|
||||
'--acpi:`acpi` command parser'
|
||||
'--airport:`airport -I` command parser'
|
||||
@@ -151,7 +151,9 @@ _jc() {
|
||||
'--crontab:`crontab` command and file parser'
|
||||
'--crontab-u:`crontab` file parser with user support'
|
||||
'--csv:CSV file parser'
|
||||
'--csv-ih:CSV implicit header file parser'
|
||||
'--csv-s:CSV file streaming parser'
|
||||
'--csv-ih-s:CSV implicit header file streaming parser'
|
||||
'--curl-head:`curl --head` command parser'
|
||||
'--date:`date` command parser'
|
||||
'--datetime-iso:ISO 8601 Datetime string parser'
|
||||
@@ -331,7 +333,12 @@ _jc() {
|
||||
'--tracepath:`tracepath` and `tracepath6` command parser'
|
||||
'--traceroute:`traceroute` and `traceroute6` command parser'
|
||||
'--traceroute-s:`traceroute` and `traceroute6` command streaming parser'
|
||||
'--tsv:TSV file parser'
|
||||
'--tsv-ih:TSV implicit header file parser'
|
||||
'--tsv-s:TSV file streaming parser'
|
||||
'--tsv-ih-s:TSV implicit header file streaming parser'
|
||||
'--tune2fs:`tune2fs -l` command parser'
|
||||
'--typeset:`typeset` and `declare` command parser'
|
||||
'--udevadm:`udevadm info` command parser'
|
||||
'--ufw:`ufw status` command parser'
|
||||
'--ufw-appinfo:`ufw app info [application]` command parser'
|
||||
|
||||
@@ -160,4 +160,4 @@ Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Source: [`jc/parsers/certbot.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/certbot.py)
|
||||
|
||||
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
+9
-5
@@ -84,16 +84,20 @@ Examples:
|
||||
```python
|
||||
def parse(data: Union[str, bytes],
|
||||
raw: bool = False,
|
||||
quiet: bool = False) -> List[Dict[str, Any]]
|
||||
quiet: bool = False,
|
||||
implicit_header: bool = False,
|
||||
tsv: bool = False) -> List[Dict[str, Any]]
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
implicit_header: (boolean) data has no header, generate column names
|
||||
tsv: (boolean) force TSV delimiter
|
||||
|
||||
Returns:
|
||||
|
||||
@@ -104,4 +108,4 @@ Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Source: [`jc/parsers/csv.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/csv.py)
|
||||
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.csv_ih"></a>
|
||||
|
||||
# jc.parsers.csv_ih
|
||||
|
||||
jc - JSON Convert `csv` implicit header file parser
|
||||
|
||||
The `csv` implicit header parser will attempt to automatically detect the
|
||||
delimiter character. If the delimiter cannot be detected it will default to
|
||||
comma. The file must have no header, and the field names will be generated
|
||||
as "c0", "c1", etc.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ cat file.csv | jc --csv-ih
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('csv_ih', csv_output)
|
||||
|
||||
Schema:
|
||||
|
||||
CSV file converted to a Dictionary:
|
||||
https://docs.python.org/3/library/csv.html
|
||||
|
||||
[
|
||||
{
|
||||
"column_name1": string,
|
||||
"column_name2": string
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ cat homes.csv
|
||||
142, 160, 28, 10, 5, 3, 60, 0.28, 3167
|
||||
175, 180, 18, 8, 4, 1, 12, 0.43, 4033
|
||||
129, 132, 13, 6, 3, 1, 41, 0.33, 1471
|
||||
...
|
||||
|
||||
$ cat homes.csv | jc --csv-ih -p
|
||||
[
|
||||
{
|
||||
"c0": "142",
|
||||
"c1": "160",
|
||||
"c2": "28",
|
||||
"c3": "10",
|
||||
"c4": "5",
|
||||
"c5": "3",
|
||||
"c6": "60",
|
||||
"c7": "0.28",
|
||||
"c8": "3167"
|
||||
},
|
||||
{
|
||||
"c0": "175",
|
||||
"c1": "180",
|
||||
"c2": "18",
|
||||
"c3": "8",
|
||||
"c4": "4",
|
||||
"c5": "1",
|
||||
"c6": "12",
|
||||
"c7": "0.43",
|
||||
"c8": "4033"
|
||||
},
|
||||
{
|
||||
"c0": "129",
|
||||
"c1": "132",
|
||||
"c2": "13",
|
||||
"c3": "6",
|
||||
"c4": "3",
|
||||
"c5": "1",
|
||||
"c6": "41",
|
||||
"c7": "0.33",
|
||||
"c8": "1471"
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
<a id="jc.parsers.csv_ih.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data: Union[str, bytes],
|
||||
raw: bool = False,
|
||||
quiet: bool = False) -> List[Dict[str, Any]]
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Source: [`jc/parsers/csv_ih.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/csv_ih.py)
|
||||
|
||||
Version 1.0 by Gary Gurlaskie (https://github.com/garyg1)
|
||||
@@ -0,0 +1,87 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.csv_ih_s"></a>
|
||||
|
||||
# jc.parsers.csv_ih_s
|
||||
|
||||
jc - JSON Convert `csv` implicit header file streaming parser
|
||||
|
||||
> This streaming parser outputs JSON Lines (cli) or returns an Iterable of
|
||||
> Dictionaries (module)
|
||||
|
||||
The `csv` implicit header parser will attempt to automatically detect the
|
||||
delimiter character. If the delimiter cannot be detected it will default to
|
||||
comma. The file must have no header, and the field names will be generated
|
||||
as "c0", "c1", etc.
|
||||
|
||||
> Note: The first 100 rows are read into memory to enable delimiter
|
||||
> detection, then the rest of the rows are loaded lazily.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ cat file.csv | jc --csv-ih
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('csv_ih', csv_output)
|
||||
|
||||
Schema:
|
||||
|
||||
CSV file converted to a Dictionary:
|
||||
https://docs.python.org/3/library/csv.html
|
||||
|
||||
{
|
||||
"c0": string,
|
||||
"c1": string,
|
||||
|
||||
# below object only exists if using -qq or ignore_exceptions=True
|
||||
"_jc_meta": {
|
||||
"success": boolean, # false if error parsing
|
||||
"error": string, # exists if "success" is false
|
||||
"line": string # exists if "success" is false
|
||||
}
|
||||
}
|
||||
|
||||
Examples:
|
||||
|
||||
$ cat homes.csv
|
||||
142, 160, 28, 10, 5, 3, 60, 0.28, 3167
|
||||
175, 180, 18, 8, 4, 1, 12, 0.43, 4033
|
||||
129, 132, 13, 6, 3, 1, 41, 0.33, 1471
|
||||
...
|
||||
|
||||
$ cat homes.csv | jc --csv-ih-s
|
||||
{"c0":"142","c1":"160","c2":"28","c3":"10","c4":"5"...}
|
||||
{"c0":"175","c1":"180","c2":"18","c3":"8","c4":"4"...}
|
||||
{"c0":"129","c1":"132","c2":"13","c3":"6","c4":"3"...}
|
||||
...
|
||||
|
||||
<a id="jc.parsers.csv_ih_s.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data: Union[str, bytes],
|
||||
raw: bool = False,
|
||||
quiet: bool = False,
|
||||
ignore_exceptions: bool = False) -> List[Dict[str, Any]]
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Source: [`jc/parsers/csv_ih_s.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/csv_ih_s.py)
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
@@ -64,7 +64,14 @@ Examples:
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data, raw=False, quiet=False, ignore_exceptions=False)
|
||||
def parse(
|
||||
data: Iterable[str],
|
||||
raw: bool = False,
|
||||
quiet: bool = False,
|
||||
ignore_exceptions: bool = False,
|
||||
implicit_header: bool = False,
|
||||
tsv: bool = False
|
||||
) -> Iterator[Union[Dict[str, Any], Tuple[BaseException, str]]]
|
||||
```
|
||||
|
||||
Main text parsing generator function. Returns an iterable object.
|
||||
@@ -87,4 +94,4 @@ Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Source: [`jc/parsers/csv_s.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/csv_s.py)
|
||||
|
||||
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
+1
-1
@@ -145,4 +145,4 @@ Compatibility: win32
|
||||
|
||||
Source: [`jc/parsers/dir.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/dir.py)
|
||||
|
||||
Version 1.6 by Rasheed Elsaleh (rasheed@rebelliondefense.com)
|
||||
Version 1.7 by Rasheed Elsaleh (rasheed@rebelliondefense.com)
|
||||
|
||||
@@ -33,6 +33,7 @@ Schema:
|
||||
[
|
||||
{
|
||||
"filename": string,
|
||||
"mode": string,
|
||||
"hash": string,
|
||||
}
|
||||
]
|
||||
@@ -43,26 +44,32 @@ Examples:
|
||||
[
|
||||
{
|
||||
"filename": "devtoolset-3-gcc-4.9.2-6.el7.x86_64.rpm",
|
||||
"mode": "text",
|
||||
"hash": "65fc958c1add637ec23c4b137aecf3d3"
|
||||
},
|
||||
{
|
||||
"filename": "digout",
|
||||
"mode": "text",
|
||||
"hash": "5b9312ee5aff080927753c63a347707d"
|
||||
},
|
||||
{
|
||||
"filename": "dmidecode.out",
|
||||
"mode": "text",
|
||||
"hash": "716fd11c2ac00db109281f7110b8fb9d"
|
||||
},
|
||||
{
|
||||
"filename": "file with spaces in the name",
|
||||
"mode": "text",
|
||||
"hash": "d41d8cd98f00b204e9800998ecf8427e"
|
||||
},
|
||||
{
|
||||
"filename": "id-centos.out",
|
||||
"mode": "text",
|
||||
"hash": "4295be239a14ad77ef3253103de976d2"
|
||||
},
|
||||
{
|
||||
"filename": "ifcfg.json",
|
||||
"mode": "text",
|
||||
"hash": "01fda0d9ba9a75618b072e64ff512b43"
|
||||
},
|
||||
...
|
||||
@@ -93,4 +100,4 @@ Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||
|
||||
Source: [`jc/parsers/hashsum.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/hashsum.py)
|
||||
|
||||
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -242,4 +242,4 @@ Compatibility: linux, aix, freebsd, darwin
|
||||
|
||||
Source: [`jc/parsers/ifconfig.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/ifconfig.py)
|
||||
|
||||
Version 2.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 2.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -197,4 +197,4 @@ Compatibility: linux
|
||||
|
||||
Source: [`jc/parsers/iptables.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/iptables.py)
|
||||
|
||||
Version 1.12 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.13 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
jc - JSON Convert `lsattr` command output parser
|
||||
|
||||
> Note: filenames with newlines are not supported.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ lsattr | jc --lsattr
|
||||
@@ -88,4 +90,4 @@ Compatibility: linux
|
||||
|
||||
Source: [`jc/parsers/lsattr.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/lsattr.py)
|
||||
|
||||
Version 1.0 by Mark Rotner (rotner.mr@gmail.com)
|
||||
Version 1.1 by Mark Rotner (rotner.mr@gmail.com)
|
||||
|
||||
@@ -31,7 +31,10 @@ Schema:
|
||||
"license": string,
|
||||
"location": string,
|
||||
"requires": string,
|
||||
"required_by": string
|
||||
"required_by": string,
|
||||
"files": [
|
||||
string
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
@@ -90,4 +93,4 @@ Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Source: [`jc/parsers/pip_show.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/pip_show.py)
|
||||
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -191,4 +191,4 @@ Compatibility: linux
|
||||
|
||||
Source: [`jc/parsers/proc_pid_smaps.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/proc_pid_smaps.py)
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
+20
-2
@@ -9,6 +9,8 @@ Supports the `-i` or `--itemize-changes` options with all levels of
|
||||
verbosity. This parser will process the `STDOUT` output or a log file
|
||||
generated with the `--log-file` option.
|
||||
|
||||
The `--stats` or `--info=stats[1-3]` options are also supported.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ rsync -i -a source/ dest | jc --rsync
|
||||
@@ -42,7 +44,21 @@ Schema:
|
||||
"false_alarms": integer,
|
||||
"data": integer,
|
||||
"bytes_sec": float,
|
||||
"speedup": float
|
||||
"speedup": float,
|
||||
"total_files": integer,
|
||||
"regular_files": integer,
|
||||
"dir_files": integer,
|
||||
"total_created_files": integer,
|
||||
"created_regular_files": integer,
|
||||
"created_dir_files": integer,
|
||||
"deleted_files": integer,
|
||||
"transferred_files": integer,
|
||||
"transferred_file_size": integer,
|
||||
"literal_data": integer,
|
||||
"matched_data": integer,
|
||||
"file_list_size": integer,
|
||||
"file_list_generation_time": float,
|
||||
"file_list_transfer_time": float,
|
||||
},
|
||||
"files": [
|
||||
{
|
||||
@@ -67,6 +83,8 @@ Schema:
|
||||
}
|
||||
]
|
||||
|
||||
Size values are in bytes.
|
||||
|
||||
[0] 'file sent', 'file received', 'local change or creation',
|
||||
'hard link', 'not updated', 'message'
|
||||
[1] 'file', 'directory', 'symlink', 'device', 'special file'
|
||||
@@ -159,4 +177,4 @@ Compatibility: linux, darwin, freebsd
|
||||
|
||||
Source: [`jc/parsers/rsync.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/rsync.py)
|
||||
|
||||
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -12,6 +12,8 @@ Supports the `-i` or `--itemize-changes` options with all levels of
|
||||
verbosity. This parser will process the `STDOUT` output or a log file
|
||||
generated with the `--log-file` option.
|
||||
|
||||
The `--stats` or `--info=stats[1-3]` options are also supported.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ rsync -i -a source/ dest | jc --rsync-s
|
||||
@@ -69,6 +71,8 @@ Schema:
|
||||
}
|
||||
}
|
||||
|
||||
Size values are in bytes.
|
||||
|
||||
[0] 'file sent', 'file received', 'local change or creation',
|
||||
'hard link', 'not updated', 'message'
|
||||
[1] 'file', 'directory', 'symlink', 'device', 'special file'
|
||||
@@ -115,4 +119,4 @@ Compatibility: linux, darwin, freebsd
|
||||
|
||||
Source: [`jc/parsers/rsync_s.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/rsync_s.py)
|
||||
|
||||
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.tsv"></a>
|
||||
|
||||
# jc.parsers.tsv
|
||||
|
||||
jc - JSON Convert `tsv` file parser
|
||||
|
||||
The `tsv` parser is a clone of the `csv` parser that uses '\t'
|
||||
as the delimiter character. The first row of the file must be a header row.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ cat file.tsv | jc --tsv
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('tsv', tsv_output)
|
||||
|
||||
Schema:
|
||||
|
||||
TSV file converted to a Dictionary:
|
||||
https://docs.python.org/3/library/csv.html
|
||||
|
||||
[
|
||||
{
|
||||
"column_name1": string,
|
||||
"column_name2": string
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ cat homes.tsv
|
||||
"Sell" "List" "Living" "Rooms" "Beds" "Baths" "Age" "Acres"...
|
||||
142 160 28 10 5 3 60 0.28 3167
|
||||
175 180 18 8 4 1 12 0.43 4033
|
||||
129 132 13 6 3 1 41 0.33 1471
|
||||
...
|
||||
|
||||
$ cat homes.tsv | jc --tsv -p
|
||||
[
|
||||
{
|
||||
"Sell": "142",
|
||||
"List": "160",
|
||||
"Living": "28",
|
||||
"Rooms": "10",
|
||||
"Beds": "5",
|
||||
"Baths": "3",
|
||||
"Age": "60",
|
||||
"Acres": "0.28",
|
||||
"Taxes": "3167"
|
||||
},
|
||||
{
|
||||
"Sell": "175",
|
||||
"List": "180",
|
||||
"Living": "18",
|
||||
"Rooms": "8",
|
||||
"Beds": "4",
|
||||
"Baths": "1",
|
||||
"Age": "12",
|
||||
"Acres": "0.43",
|
||||
"Taxes": "4033"
|
||||
},
|
||||
{
|
||||
"Sell": "129",
|
||||
"List": "132",
|
||||
"Living": "13",
|
||||
"Rooms": "6",
|
||||
"Beds": "3",
|
||||
"Baths": "1",
|
||||
"Age": "41",
|
||||
"Acres": "0.33",
|
||||
"Taxes": "1471"
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
<a id="jc.parsers.tsv.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data: Union[str, bytes],
|
||||
raw: bool = False,
|
||||
quiet: bool = False) -> List[Dict[str, Any]]
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Source: [`jc/parsers/tsv.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/tsv.py)
|
||||
|
||||
Version 1.0 by Gary Gurlaskie (https://github.com/garyg1)
|
||||
@@ -0,0 +1,106 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.tsv_ih"></a>
|
||||
|
||||
# jc.parsers.tsv_ih
|
||||
|
||||
jc - JSON Convert `tsv` implicit header file parser
|
||||
|
||||
The `tsv` implicit header file parser is a clone of the `csv` implicit
|
||||
header file parser that uses '\t' as the delimiter character. The file must
|
||||
have no header, and the field names will be generated as "c0", "c1", etc.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ cat file.tsv | jc --tsv-ih
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('tsv_ih', tsv_output)
|
||||
|
||||
Schema:
|
||||
|
||||
TSV file converted to a Dictionary:
|
||||
https://docs.python.org/3/library/csv.html
|
||||
|
||||
[
|
||||
{
|
||||
"c0": string,
|
||||
"c1": string
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ cat homes.tsv
|
||||
142 160 28 10 5 3 60 0.28 3167
|
||||
175 180 18 8 4 1 12 0.43 4033
|
||||
129 132 13 6 3 1 41 0.33 1471
|
||||
...
|
||||
|
||||
$ cat homes.tsv | jc --tsv-ih -p
|
||||
[
|
||||
{
|
||||
"c0": "142",
|
||||
"c1": "160",
|
||||
"c2": "28",
|
||||
"c3": "10",
|
||||
"c4": "5",
|
||||
"c5": "3",
|
||||
"c6": "60",
|
||||
"c7": "0.28",
|
||||
"c8": "3167"
|
||||
},
|
||||
{
|
||||
"c0": "175",
|
||||
"c1": "180",
|
||||
"c2": "18",
|
||||
"c3": "8",
|
||||
"c4": "4",
|
||||
"c5": "1",
|
||||
"c6": "12",
|
||||
"c7": "0.43",
|
||||
"c8": "4033"
|
||||
},
|
||||
{
|
||||
"c0": "129",
|
||||
"c1": "132",
|
||||
"c2": "13",
|
||||
"c3": "6",
|
||||
"c4": "3",
|
||||
"c5": "1",
|
||||
"c6": "41",
|
||||
"c7": "0.33",
|
||||
"c8": "1471"
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
<a id="jc.parsers.tsv_ih.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data: Union[str, bytes],
|
||||
raw: bool = False,
|
||||
quiet: bool = False) -> List[Dict[str, Any]]
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Source: [`jc/parsers/tsv_ih.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/tsv_ih.py)
|
||||
|
||||
Version 1.0 by Gary Gurlaskie (https://github.com/garyg1)
|
||||
@@ -0,0 +1,87 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.tsv_ih_s"></a>
|
||||
|
||||
# jc.parsers.tsv_ih_s
|
||||
|
||||
jc - JSON Convert `TSV` implicit header file streaming parser
|
||||
|
||||
> This streaming parser outputs JSON Lines (cli) or returns an Iterable of
|
||||
> Dictionaries (module)
|
||||
|
||||
The `tsv` implicit header file streaming parser is a clone of the `csv`
|
||||
implicit header file streaming parser that uses '\t' as the delimiter
|
||||
character. The file must have no header, and the field names will be
|
||||
generated as "c0", "c1", etc.
|
||||
|
||||
> Note: The first 100 rows are read into memory for file analysis, then the
|
||||
> rest of the rows are loaded lazily.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ cat file.tsv | jc --tsv-ih-s
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('tsv_ih_s', tsv_output)
|
||||
|
||||
Schema:
|
||||
|
||||
TSV file converted to a Dictionary:
|
||||
https://docs.python.org/3/library/csv.html
|
||||
|
||||
{
|
||||
"c0": string,
|
||||
"c1": string,
|
||||
|
||||
# below object only exists if using -qq or ignore_exceptions=True
|
||||
"_jc_meta": {
|
||||
"success": boolean, # false if error parsing
|
||||
"error": string, # exists if "success" is false
|
||||
"line": string # exists if "success" is false
|
||||
}
|
||||
}
|
||||
|
||||
Examples:
|
||||
|
||||
$ cat homes.tsv
|
||||
142 160 28 10 5 3 60 0.28 3167
|
||||
175 180 18 8 4 1 12 0.43 4033
|
||||
129 132 13 6 3 1 41 0.33 1471
|
||||
...
|
||||
|
||||
$ cat homes.tsv | jc --tsv-ih-s -p
|
||||
{"c0":"142","c1":"160","c2":"28","c3":"10","c4":"5"...}
|
||||
{"c0":"175","c1":"180","c2":"18","c3":"8","c4":"4"...}
|
||||
{"c0":"129","c1":"132","c2":"13","c3":"6","c4":"3"...}
|
||||
...
|
||||
|
||||
<a id="jc.parsers.tsv_ih_s.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data: Union[str, bytes],
|
||||
raw: bool = False,
|
||||
quiet: bool = False,
|
||||
ignore_exceptions: bool = False) -> List[Dict[str, Any]]
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Source: [`jc/parsers/tsv_ih_s.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/tsv_ih_s.py)
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
@@ -0,0 +1,86 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.tsv_s"></a>
|
||||
|
||||
# jc.parsers.tsv_s
|
||||
|
||||
jc - JSON Convert `TSV` file streaming parser
|
||||
|
||||
> This streaming parser outputs JSON Lines (cli) or returns an Iterable of
|
||||
> Dictionaries (module)
|
||||
|
||||
The `tsv` streaming parser is a clone of the `csv` streaming parser that
|
||||
uses '\t' as the delimiter character. The first row of the file must be a
|
||||
header row.
|
||||
|
||||
> Note: The first 100 rows are read into memory for file analysis, then the
|
||||
> rest of the rows are loaded lazily.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ cat file.csv | jc --tsv-s
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('tsv_s', tsv_output)
|
||||
|
||||
Schema:
|
||||
|
||||
TSV file converted to a Dictionary:
|
||||
https://docs.python.org/3/library/csv.html
|
||||
|
||||
{
|
||||
"column_name1": string,
|
||||
"column_name2": string,
|
||||
|
||||
# below object only exists if using -qq or ignore_exceptions=True
|
||||
"_jc_meta": {
|
||||
"success": boolean, # false if error parsing
|
||||
"error": string, # exists if "success" is false
|
||||
"line": string # exists if "success" is false
|
||||
}
|
||||
}
|
||||
|
||||
Examples:
|
||||
|
||||
$ cat homes.tsv
|
||||
"Sell" "List" "Living" "Rooms" "Beds" "Baths" "Age" "Acres"...
|
||||
142 160 28 10 5 3 60 0.28 3167
|
||||
175 180 18 8 4 1 12 0.43 4033
|
||||
129 132 13 6 3 1 41 0.33 1471
|
||||
...
|
||||
|
||||
$ cat homes.tsv | jc --tsv-s
|
||||
{"Sell":"142","List":"160","Living":"28","Rooms":"10","Beds":"5"...}
|
||||
{"Sell":"175","List":"180","Living":"18","Rooms":"8","Beds":"4"...}
|
||||
{"Sell":"129","List":"132","Living":"13","Rooms":"6","Beds":"3"...}
|
||||
|
||||
<a id="jc.parsers.tsv_s.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data: Union[str, bytes],
|
||||
raw: bool = False,
|
||||
quiet: bool = False,
|
||||
ignore_exceptions: bool = False) -> List[Dict[str, Any]]
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Source: [`jc/parsers/tsv_s.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/tsv_s.py)
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
@@ -0,0 +1,149 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.typeset"></a>
|
||||
|
||||
# jc.parsers.typeset
|
||||
|
||||
jc - JSON Convert `typeset` and `declare` Bash internal command output parser
|
||||
|
||||
Convert `typeset` and `declare` bash internal commands with no options or the
|
||||
following: `-a`, `-A`, `-i`, `-l`, `-p`, `-r`, `-u`, and `-x`
|
||||
|
||||
Note: function parsing is not supported (e.g. `-f` or `-F`)
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ typeset | jc --typeset
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('typeset', typeset_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"name": string,
|
||||
"value": string/integer/array/object/null, # [0]
|
||||
"type": string, # [1]
|
||||
"readonly": boolean/null,
|
||||
"integer": boolean/null,
|
||||
"lowercase": boolean/null,
|
||||
"uppercase": boolean/null,
|
||||
"exported": boolean/null
|
||||
}
|
||||
]
|
||||
|
||||
Key/value pairs other than `name`, `value`, and `type` will only be non-null
|
||||
when the information is available from the `typeset` or `declare` output.
|
||||
|
||||
If declare options are not given to `jc` within the `typeset` output, then
|
||||
it will assume all arrays are simple `array` type.
|
||||
|
||||
[0] Based on type. `variable` type is null if not set, a string when the
|
||||
bash variable is set unless the `integer` field is set to `True`, then
|
||||
the type is integer. `array` type is an array of strings or integers as
|
||||
above. `associative` type is an object of key/value pairs where values
|
||||
are strings or integers as above. Objects have the schema of:
|
||||
|
||||
{
|
||||
"<key1>": string/integer,
|
||||
"<key2>": string/integer
|
||||
}
|
||||
|
||||
[1] Possible values: `variable`, `array`, or `associative`
|
||||
|
||||
Examples:
|
||||
|
||||
$ typeset -p | jc --typeset -p
|
||||
[
|
||||
{
|
||||
"name": "associative_array",
|
||||
"value": {
|
||||
"key2": "abc",
|
||||
"key3": "1 2 3",
|
||||
"key1": "hello \"world\""
|
||||
},
|
||||
"type": "associative",
|
||||
"readonly": false,
|
||||
"integer": false,
|
||||
"lowercase": false,
|
||||
"uppercase": false,
|
||||
"exported": false
|
||||
},
|
||||
{
|
||||
"name": "integers_associative_array",
|
||||
"value": {
|
||||
"one": 1,
|
||||
"two": 500,
|
||||
"three": 999
|
||||
},
|
||||
"type": "associative",
|
||||
"readonly": false,
|
||||
"integer": true,
|
||||
"lowercase": false,
|
||||
"uppercase": false,
|
||||
"exported": false
|
||||
}
|
||||
]
|
||||
|
||||
$ typeset -p | jc --typeset -p -r
|
||||
[
|
||||
{
|
||||
"name": "associative_array",
|
||||
"value": {
|
||||
"key2": "abc",
|
||||
"key3": "1 2 3",
|
||||
"key1": "hello \"world\""
|
||||
},
|
||||
"type": "associative",
|
||||
"readonly": false,
|
||||
"integer": false,
|
||||
"lowercase": false,
|
||||
"uppercase": false,
|
||||
"exported": false
|
||||
},
|
||||
{
|
||||
"name": "integers_associative_array",
|
||||
"value": {
|
||||
"one": "1",
|
||||
"two": "500",
|
||||
"three": "999"
|
||||
},
|
||||
"type": "associative",
|
||||
"readonly": false,
|
||||
"integer": true,
|
||||
"lowercase": false,
|
||||
"uppercase": false,
|
||||
"exported": false
|
||||
}
|
||||
]
|
||||
|
||||
<a id="jc.parsers.typeset.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data: str,
|
||||
raw: bool = False,
|
||||
quiet: bool = False) -> List[Dict[str, Any]]
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Source: [`jc/parsers/typeset.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/typeset.py)
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
+6
-1
@@ -31,6 +31,7 @@ Schema:
|
||||
"action": string,
|
||||
"action_direction": string, # null if blank
|
||||
"index": integer, # null if blank
|
||||
"log": boolean,
|
||||
"network_protocol": string,
|
||||
"to_ip": string,
|
||||
"to_ip_prefix": integer,
|
||||
@@ -82,6 +83,7 @@ Examples:
|
||||
"action": "ALLOW",
|
||||
"action_direction": "IN",
|
||||
"index": null,
|
||||
"log": true,
|
||||
"network_protocol": "ipv4",
|
||||
"to_interface": "any",
|
||||
"to_transport": "any",
|
||||
@@ -108,6 +110,7 @@ Examples:
|
||||
"action": "ALLOW",
|
||||
"action_direction": "IN",
|
||||
"index": null,
|
||||
"log": false,
|
||||
"network_protocol": "ipv4",
|
||||
"to_interface": "any",
|
||||
"to_transport": "tcp",
|
||||
@@ -147,6 +150,7 @@ Examples:
|
||||
"action": "ALLOW",
|
||||
"action_direction": "IN",
|
||||
"index": null,
|
||||
"log": true,
|
||||
"network_protocol": "ipv4",
|
||||
"to_interface": "any",
|
||||
"to_transport": "any",
|
||||
@@ -173,6 +177,7 @@ Examples:
|
||||
"action": "ALLOW",
|
||||
"action_direction": "IN",
|
||||
"index": null,
|
||||
"log": false,
|
||||
"network_protocol": "ipv4",
|
||||
"to_interface": "any",
|
||||
"to_transport": "tcp",
|
||||
@@ -225,4 +230,4 @@ Compatibility: linux
|
||||
|
||||
Source: [`jc/parsers/ufw.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/ufw.py)
|
||||
|
||||
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
|
||||
# jc.parsers.ufw_appinfo
|
||||
|
||||
jc - JSON Convert `ufw app info [application]` command
|
||||
output parser
|
||||
jc - JSON Convert `ufw app info [application]` command output parser
|
||||
|
||||
Supports individual apps via `ufw app info [application]` and all apps list
|
||||
via `ufw app info all`.
|
||||
|
||||
@@ -52,7 +52,7 @@ class info():
|
||||
author: str = 'Kelly Brazil'
|
||||
author_email: str = 'kellyjonbrazil@gmail.com'
|
||||
website: str = 'https://github.com/kellyjonbrazil/jc'
|
||||
copyright: str = '© 2019-2025 Kelly Brazil'
|
||||
copyright: str = '© 2019-2026 Kelly Brazil'
|
||||
license: str = 'MIT License'
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.TH jc 1 2025-10-12 1.25.6 "JSON Convert"
|
||||
.TH jc 1 2026-06-18 1.25.7 "JSON Convert"
|
||||
.SH NAME
|
||||
\fBjc\fP \- JSON Convert JSONifies the output of many CLI tools, file-types,
|
||||
and strings
|
||||
@@ -147,11 +147,21 @@ Common and Combined Log Format file streaming parser
|
||||
\fB--csv\fP
|
||||
CSV file parser
|
||||
|
||||
.TP
|
||||
.B
|
||||
\fB--csv-ih\fP
|
||||
CSV implicit header file parser
|
||||
|
||||
.TP
|
||||
.B
|
||||
\fB--csv-s\fP
|
||||
CSV file streaming parser
|
||||
|
||||
.TP
|
||||
.B
|
||||
\fB--csv-ih-s\fP
|
||||
CSV implicit header file streaming parser
|
||||
|
||||
.TP
|
||||
.B
|
||||
\fB--curl-head\fP
|
||||
@@ -1047,11 +1057,36 @@ TOML file parser
|
||||
\fB--traceroute-s\fP
|
||||
`traceroute` and `traceroute6` command streaming parser
|
||||
|
||||
.TP
|
||||
.B
|
||||
\fB--tsv\fP
|
||||
TSV file parser
|
||||
|
||||
.TP
|
||||
.B
|
||||
\fB--tsv-ih\fP
|
||||
TSV implicit header file parser
|
||||
|
||||
.TP
|
||||
.B
|
||||
\fB--tsv-s\fP
|
||||
TSV file streaming parser
|
||||
|
||||
.TP
|
||||
.B
|
||||
\fB--tsv-ih-s\fP
|
||||
TSV implicit header file streaming parser
|
||||
|
||||
.TP
|
||||
.B
|
||||
\fB--tune2fs\fP
|
||||
`tune2fs -l` command parser
|
||||
|
||||
.TP
|
||||
.B
|
||||
\fB--typeset\fP
|
||||
`typeset` and `declare` command parser
|
||||
|
||||
.TP
|
||||
.B
|
||||
\fB--udevadm\fP
|
||||
@@ -1662,6 +1697,6 @@ Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
https://github.com/kellyjonbrazil/jc
|
||||
|
||||
.SH COPYRIGHT
|
||||
Copyright (c) 2019-2025 Kelly Brazil
|
||||
Copyright (c) 2019-2026 Kelly Brazil
|
||||
|
||||
License: MIT License
|
||||
Reference in New Issue
Block a user