Giter Site home page Giter Site logo

wfxr / csview Goto Github PK

View Code? Open in Web Editor NEW
526.0 526.0 13.0 301 KB

πŸ“  Pretty and fast csv viewer for cli with cjk/emoji support.

Home Page: https://github.com/wfxr/csview

License: Apache License 2.0

Rust 100.00%
cjk cli command-line csv pager rust table terminal tool

csview's People

Contributors

0x5c avatar bingoohuang avatar dependabot[bot] avatar frisoft avatar ritschwumm avatar wfxr avatar zhiburt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

csview's Issues

Input csview command without parameter will get no repsonse in terminal

Check list

  • I have read through the README
  • I have searched through the existing issues

Environment info

  • OS
    • Linux
    • Mac OS X
    • Windows
    • Others:

Version

csview v0.3.4

Problem / Steps to reproduce

Input csview command without parameter will get no repsonse in terminal. It seems something wrong? I think the csview cli should check the input parameters and if no input parameter are given (eg, only input csview in terminal), error message should be given for better user experience.

UTF-8 Error

Hello, I think I've found a bug and would like to report it to you.
Reported behavior: open a csv file and application crashes with utf-8 error.

Tested on this dataset: https://catalog.data.gov/dataset/traffic-data/resource/e46a5cc5-ed4d-4b8d-b750-18e6c9ec570e
Exact command:
csview monroe-county-crash-data2003-to-2015.csv

Backtrace:

thread 'main' panicked at 'called Result::unwrap()on anErrvalue: Error(Utf8 { pos: Some(Position { byte: 512345, line: 4326, record: 4326 }), err: Utf8Error { field: 9, valid_up_to: 18 } })', src/core.rs:12:37 note: run withRUST_BACKTRACE=1environment variable to display a backtrace myuser@pop-os:~/Downloads$ RUST_BACKTRACE=1 csview monroe-county-crash-data2003-to-2015.csv thread 'main' panicked at 'calledResult::unwrap()on anErrvalue: Error(Utf8 { pos: Some(Position { byte: 512345, line: 4326, record: 4326 }), err: Utf8Error { field: 9, valid_up_to: 18 } })', src/core.rs:12:37 stack backtrace: 0: backtrace::backtrace::libunwind::trace at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86 1: backtrace::backtrace::trace_unsynchronized at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66 2: std::sys_common::backtrace::_print_fmt at src/libstd/sys_common/backtrace.rs:78 3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt at src/libstd/sys_common/backtrace.rs:59 4: core::fmt::write at src/libcore/fmt/mod.rs:1076 5: std::io::Write::write_fmt at src/libstd/io/mod.rs:1537 6: std::sys_common::backtrace::_print at src/libstd/sys_common/backtrace.rs:62 7: std::sys_common::backtrace::print at src/libstd/sys_common/backtrace.rs:49 8: std::panicking::default_hook::{{closure}} at src/libstd/panicking.rs:198 9: std::panicking::default_hook at src/libstd/panicking.rs:217 10: std::panicking::rust_panic_with_hook at src/libstd/panicking.rs:526 11: rust_begin_unwind at src/libstd/panicking.rs:437 12: core::panicking::panic_fmt at src/libcore/panicking.rs:85 13: core::option::expect_none_failed at src/libcore/option.rs:1269 14: <core::iter::adapters::Map<I,F> as core::iter::traits::iterator::Iterator>::next 15: csview::main 16: std::rt::lang_start::{{closure}} 17: main 18: __libc_start_main 19: _start note: Some details are omitted, run withRUST_BACKTRACE=fullfor a verbose backtrace.

Version of csview: 0.3.2-rc.0
OS: Pop!_OS 20.04 with Xanmod Kernel

Thank you very much in advance.

feature request: introduce paging and search

Check list

  • I have read through the README
  • I have searched through the existing issues

Request

Thank you for the great tool, I love using csview and xsv together! Would it be possible to have csview behave more like a pager, namely to actually page the output when long, instead of having to manually pipe it again into less? Whilst I understand the complexity of having to introduce a pager within an application, do you think that can be considered in scope (perhaps in the future)?

Having to always pipe into less makes csview a little less independent as tool, as one would still have to use another application (less) to search and display results on terminal.

Expose `Table` as a crate?

Hi @wfxr

There was some effort in pretty-print domain to note different libraries.
zhiburt/tabled#139

Because I know that csview does pretty efficient csv printing.
I was thinking if you'd expose it, I could highlight it.

Let me know if you're interested.

Take care.


I think,
You could do it relatively effortlessly.
Just create a lib.rs and expose the functions.

Introduce `--sort`: Sort by Header

Check list

  • I have read through the README
  • I have searched through the existing issues

Environment info

  • OS
    • Linux
    • Mac OS X
    • Windows
    • Others:

Version

csview 1.2.2

Problem / Steps to reproduce

Thanks for such an awesome project! This is rock! πŸ”₯

It would be nice to have a (--sort|--sort-by|--sort-asc|--sort-dsc) flag to sort items by providing header name: (I'm not sure about the flag namings)

"h1", "h2", "h3"
"ccc", "bbb", "aaa"
"bbb", "ccc", "bbb"
"aaa", "aaa", "ccc"

For example:

  • csview --sort-asc h1:
"h1", "h2", "h3"
"aaa", "aaa", "ccc"
"bbb", "ccc", "bbb"
"ccc", "bbb", "aaa"
  • csview --sort-dsc h2:
"h1", "h2", "h3"
"bbb", "ccc", "bbb"
"ccc", "bbb", "aaa"
"aaa", "aaa", "ccc"

WDYT?

Make it more user-friendly

$ echo Name;Age;Sex; > test.csv

$ csview.exe test.csv
++
||
++
++

(checking manual…)

$ csview.exe  -d ; test.csv
++
||
++
++

(wtf…)

$ csview.exe -d ; -H test.csv
+------+-----+------+ 
| Name | Age | Sex  | 
+------+-----+------+ 

(at last!)
  1. Reverse -H not to confuse newcomer with no data displayed, or at least don’t require it in case of single line.

  2. Make csview smarter in terms of recognizing common delimiters (for example, check this and that),
    because comma is often used as decimal separator or even as is in cases like β€œPancakes;0,2kcal;Use flour, milk, eggs, honey”.

Support distribution on Linux via Linuxbrew

Check list

  • I have read through the README
  • I have searched through the existing issues

Environment info

  • OS
    • Linux
    • Mac OS X
    • Windows
    • Others:

Version

N/A

Problem / Steps to reproduce

Running brew tap wxfr/csview && brew install csview on Linux with Linuxbrew, does not result in a working csview.
I looked at the homebrew-csview repository, and the darwin binary is hard coded there.

I'm not sure if it's possible, but is there a way that you could support distributing on Linux via Linuxbrew?

[Feature] Support for flatten view

Check list

  • I have read through the README
  • I have searched through the existing issues

Environment info

  • OS
    • Linux
    • Mac OS X
    • Windows
    • Others:

Version

csview 1.2.2

Problem / Steps to reproduce

Thank you for creating such an exceptional application. I frequently need to view CSV files with extended column widths, which unfortunately, do not display well in table view. Therefore, I would like to suggest the implementation of a csview flatten feature, similar to xsv flatten, but with line separation. I believe this enhancement would greatly improve the user experience. Thank you for considering my suggestion.

question: Does csview fixed the stream rendering?

Hi @wfxr

I bump into csview by

phsym/prettytable-rs#104
#19

I think it's a great idea to not allocate the huge chunk of memory but rather do things lazily.

And I was thinking how to do it myself zhiburt/tabled#123
I was thinking about requiring Clone for iterator so 1 pass for demension the second pass when print.
But it seems to be restrictive to me.

So I looked at your ideas.

And I just wonder if you've fixed the original issue.

Specifically my concern is about this Vec allocation.

let (widths, buf) = sniff_widths(&mut rdr, header.as_ref(), sniff_rows)?;

let mut buf = Vec::new();

Am I wrong that essentially we will allocate n * m memory anyway here.

Take care.
Thank you for cross issue references :)

Check list

  • I have read through the README
  • I have searched through the existing issues

Environment info

  • OS
    • Linux
    • Mac OS X
    • Windows
    • Others:

Version

Problem / Steps to reproduce

Add it to a Ubuntu PPA for apt (does not compile on 20.04.4) ?

Check list

  • [ X] I have read through the README
  • [ X] I have searched through the existing issues

Environment info

  • OS
    • [X ] Linux
    • Mac OS X
    • Windows
    • Others:

Version

Problem / Steps to reproduce

sudo -s
apt install cargo
cargo install csview

gives this error:

   Compiling csview v1.1.0
error[E0658]: use of unstable library feature 'bool_to_option'
  --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/csview-1.1.0/src/table/mod.rs:92:50
   |
92 |     update_widths(&record, &mut widths, with_seq.then_some("#"));
   |                                                  ^^^^^^^^^
error: failed to compile `csview v1.1.0`, intermediate artifacts can be found at `/tmp/cargo-installmangP5`

I know I can install the binary

greetings, el

Multiline-wrapping

Check list

  • I have read through the README
  • I have searched through the existing issues

Environment info

  • OS
    • Linux
    • Mac OS X
    • Windows
    • Others:

Version

v1.0.1

Problem / Steps to reproduce

I do have a tsv-file with columns that contain comma-separated tags.
It would be cool if csview could display such nested structures by wrapping in multiple lines (at least if they're very long).

Example call:
cat myfile.tsv | csview -t --wrap=',' | less -S

Center Headers?

Check list

  • [ X] I have read through the README
  • [ X] I have searched through the existing issues

Environment info

  • OS
    • [ X] Linux
    • [X ] Mac OS X
    • [X ] Windows
    • Others:

Version

csview 1.1.0

Problem / Steps to reproduce

Would it be possible to center the headers of the columns (if any)?

Out-of-memory issues with large tsv-file

Check list

  • I have read through the README
  • I have searched through the existing issues

Environment info

  • OS
    • Linux
    • Mac OS X
    • Windows
    • Others:

Version

csview 0.3.6

Problem / Steps to reproduce

First of all, thanks for this very nice and useful tool.
I'd like to view a large TSV-type file but it dies because of out-of-memory.

Steps to reproduce:

  • wget https://storage.googleapis.com/gcp-public-data--gnomad/release/2.1.1/vcf/exomes/gnomad.exomes.r2.1.1.sites.1.vcf.bgz
  • zcat "gnomad.exomes.r2.1.1.sites.1.vcf.bgz" | grep -v "^##" | csview -t | less -S

Would it be possible to limit csview's memory usage and make it play nicely with less?

Align and format numbers?

Check list

  • I have read through the README
  • I have searched through the existing issues

Environment info

  • OS
    • Linux
    • Mac OS X
    • Windows
    • Others:

Version

csview 1.2.2

Problem / Steps to reproduce

I find it easier to read if numbers were right aligned. Can that be implemented (as default or by switch)?

I also find amounts easier to read if they were formatted by the thousands, either by way of the locale or by something like

qsv issue #660

or similar.

switch to turn pager off

Check list

  • [ x] I have read through the README
  • [ x] I have searched through the existing issues

Environment info

  • OS
    • Linux
    • Mac OS X
    • Windows
    • Others:

Version

1.3.0

Problem / Steps to reproduce

I like this, but I can't find an option to turn the pager off. It messes with some of my shell scripts, especially if I run a large number of them, as I have to repeatedly intervene manually.

Align numbers by dot

Check list

  • I have read through the README
  • I have searched through the existing issues

Environment info

  • OS
    • Linux
    • Mac OS X
    • Windows
    • Others:

Version

csview 1.2.2

Problem / Steps to reproduce

The output of my_number column is the following:

β”Œβ”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Id β”‚  Sex   β”‚ my_number   β”‚ Embarked β”‚
β”œβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ 1  β”‚ male   β”‚ 12345.54321 β”‚ S        β”‚
β”‚ 2  β”‚ female β”‚ 123.321     β”‚ C        β”‚
β”‚ 3  β”‚ female β”‚ 123         β”‚ S        β”‚
β”‚ 4  β”‚ female β”‚ 12.21       β”‚ S        β”‚
β”‚ 5  β”‚ male   β”‚ 1.1         β”‚ S        β”‚
β”‚ 6  β”‚ male   β”‚ 0.1         β”‚ S        β”‚
β”‚ 7  β”‚ male   β”‚ 0.01        β”‚ S        β”‚
β”‚ 8  β”‚ male   β”‚ 0.001       β”‚ S        β”‚
β””β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

The output of my_number column in my mind is the following:

β”Œβ”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Id β”‚  Sex   β”‚ my_number   β”‚ Embarked β”‚
β”œβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ 1  β”‚ male   β”‚ 12345.54321 β”‚ S        β”‚
β”‚ 2  β”‚ female β”‚   123.321   β”‚ C        β”‚
β”‚ 3  β”‚ female β”‚   123       β”‚ S        β”‚
β”‚ 4  β”‚ female β”‚    12.21    β”‚ S        β”‚
β”‚ 5  β”‚ male   β”‚     1.1     β”‚ S        β”‚
β”‚ 6  β”‚ male   β”‚     0.1     β”‚ S        β”‚
β”‚ 7  β”‚ male   β”‚     0.01    β”‚ S        β”‚
β”‚ 8  β”‚ male   β”‚     0.001   β”‚ S        β”‚
β””β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.