rendered paste body;CSV Reader
;By Panda200x
alias csvecho { if (!$window(@csv)) { window -e @csv } | echo $color(info) -e @csv $timestamp * $1- }
alias readcsv {
window -e @csv
var %csv = $1
if (!$isfile($1)) { csvecho $qt(%csv) does not exist! | halt }
var %x = 1
if ($2) { var %change = $replace($2,-,$chr(32)) | tokenize 32 %change | var %change = $1 | var %change2 = $2 }
csvecho File: %csv $chr(124) Lines in file: $lines(%csv)
while (%x <= $lines(%csv)) {
if (%x == 1) { csvecho $replace($read(%csv,1),$chr(44),$+($chr(9),$chr(9),$chr(9),$chr(9))) | var %x = $iif(%change,%change,%x) }
else { csvecho $replace($read(%csv,%x),$chr(44),$+($chr(9),$chr(9),$chr(9),$chr(9))) | var %x = $iif(%change2,$iif(%x == %change2,$calc($lines(%csv)),%x),%x) }
if (%x == $lines(%csv)) { inc %x }
inc %x
}
csvecho End of File...
}
;Dummy CSV File - copy paste everything underneath into a .txt/.csv file and read it with /readcsv *file*
hello,how,are,you
not,very,good,thanks
ah,ok,whats,wrong?