0

How could I output the contents of a .csv file to a Zenity list. The file has multiple rows and columns and the rows are no fixed numbers. I would also like it so that when the user double clicks, on one of the entries it open a Zenity form with the text field filled in so that the csv file can be update I am using a shell bash file.

I have tried by googling but have not had much luck if you can help with just part of this then please post a answer.

  • You should describe (no example) your input data more clearly. Is this full fledged csv or the csv-simple that has no newlines, separator characters or quotes in its fields? – Anthon Feb 11 '15 at 6:43
1

Input csv

$> cat data.csv

Mumbai,India
Chicago,USA
London,UK
New York,USA

Format CSV Output. Add line number split each column value with new line.

cat data.csv | \
awk -F ',' '{
    print NR; # Print Record Number 
    for(i=1;i<=NF;i++){
        print $i; # Print Each Column separeted by Default EOL
    }
}' | \
zenity --list \
--title="Title" \
--column="Index" --column="City" --column="Country" \
--print-column=2
0
$ cat lang.txt 
Brazil,Brasilia,Portugues
England,London,English
France,Paris,French
Germany,Berlim,German
$ zenity --list --title Foolish \
    --column Contry --column Capitol --column Language \
    --print-column=2 $(tr , \\n < lang.txt)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.