Skip to content

Instantly share code, notes, and snippets.

@Axel-Erfurt
Last active January 24, 2021 22:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Axel-Erfurt/03ff0c2234a6185f62521729453c5beb to your computer and use it in GitHub Desktop.
Save Axel-Erfurt/03ff0c2234a6185f62521729453c5beb to your computer and use it in GitHub Desktop.
show CSV with zenipy
import zenipy
myfile = "/path/to/file.csv"
csv = open(myfile, "r").read().splitlines()
header = "\n".join(csv[:1])
columns = header.split("\t")
t = ""
for line in csv[1:]:
values = "".join(line).split("\t")
t += "\n".join(values)
t += "\n"
zenipy.zlist(columns, t.splitlines(), text='', title=myfile, width=1000, height=500, timeout=None)
@Axel-Erfurt
Copy link
Author

Version with File selector

from zenipy import file_selection, zlist


def selectFile():
    myfile = file_selection(multiple=False, directory=False, save=False, 
                            confirm_overwrite=False, title='Open CSV', 
                            width=450, height=650, timeout=None)
    if myfile:
        return(myfile)
    else:
        return("") 
        
        
myfile = selectFile()

if not myfile == "":
    csv = open(myfile, "r").read().splitlines()

    header = "\n".join(csv[:1])

    columns = header.split("\t")

    t = ""

    for line in csv[1:]:
        values = "".join(line).split("\t")
        t += "\n".join(values)
        t += "\n"

    zlist(columns, t.splitlines(), text='', title=myfile, width=1000, height=500, timeout=None)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment