@@ -49,7 +49,7 @@ def _plot_scatter(xs, ys, size, pch, colour, title, cs):
4949 print (" |" )
5050 print ("-" * (2 * len (get_scale (xs , False , size )) + 2 ))
5151
52- def plot_scatter (f , xs , ys , size , pch , colour , title ):
52+ def plot_scatter (f , xs , ys , size , pch , colour , title , delimiter = ',' ):
5353 """
5454 Form a complex number.
5555
@@ -66,9 +66,9 @@ def plot_scatter(f, xs, ys, size, pch, colour, title):
6666 if f :
6767 if isinstance (f , str ):
6868 with open (f ) as fh :
69- data = [tuple (line .strip ().split (',' )) for line in fh ]
69+ data = [tuple (line .strip ().split (delimiter )) for line in fh ]
7070 else :
71- data = [tuple (line .strip ().split (',' )) for line in f ]
71+ data = [tuple (line .strip ().split (delimiter )) for line in f ]
7272 xs = [float (i [0 ]) for i in data ]
7373 ys = [float (i [1 ]) for i in data ]
7474 if len (data [0 ]) > 2 :
@@ -90,6 +90,7 @@ def main():
9090 parser = optparse .OptionParser (usage = scatter ['usage' ])
9191
9292 parser .add_option ('-f' , '--file' , help = 'a csv w/ x and y coordinates' , default = None , dest = 'f' )
93+ parser .add_option ('-d' , '--delimiter' , help = 'delimiter between x & y values in input file' , default = ',' )
9394 parser .add_option ('-t' , '--title' , help = 'title for the chart' , default = "" , dest = 't' )
9495 parser .add_option ('-x' , help = 'x coordinates' , default = None , dest = 'x' )
9596 parser .add_option ('-y' , help = 'y coordinates' , default = None , dest = 'y' )
@@ -104,7 +105,7 @@ def main():
104105 opts .f = sys .stdin .readlines ()
105106
106107 if opts .f or (opts .x and opts .y ):
107- plot_scatter (opts .f , opts .x , opts .y , opts .size , opts .pch , opts .colour , opts .t )
108+ plot_scatter (opts .f , opts .x , opts .y , opts .size , opts .pch , opts .colour , opts .t , opts . delimiter )
108109 else :
109110 print ("nothing to plot!" )
110111
0 commit comments