Last active 1738783289

dominic revised this gist 1738783288. Go to revision

1 file changed, 39 insertions

prettycsv.py(file created)

@@ -0,0 +1,39 @@
1 + #!/bin/env python
2 +
3 + """Print pretty csv data on terminal
4 + vim: ft=python
5 +
6 + Author: Dominic Reich <quick.hat4396@qtztsjosmprqmgtunjyf.com>
7 + Created: 2025-02-05T19:49:59+0100
8 + Last modified: 2025-02-05T19:50:07+0100
9 +
10 + Usage:
11 + ------
12 + Use with arguments (filename of csv data).
13 + ./pretty_csv <filename>
14 + """
15 +
16 + import sys
17 + import os
18 + import pandas as pd
19 +
20 +
21 + def main():
22 +
23 + if len(sys.argv) <= 1:
24 + print("Sorry, what is it?")
25 + exit(1)
26 + else:
27 + filename=sys.argv[1]
28 +
29 + if os.path.isfile(filename) and os.access(filename, os.R_OK):
30 + csv_file = pd.read_csv(filename, dtype=str)
31 +
32 + print(csv_file)
33 + else:
34 + print("File ›{}‹ not found or not readable. Aborting.".format(filename))
35 + exit(1)
36 +
37 +
38 + if __name__ == "__main__":
39 + main()
Newer Older