【发布时间】:2022-01-19 16:57:28
【问题描述】:
我想编写一个小 bash 脚本,它只是要求用户输入国家和项目。 该脚本将打开 gnuplot 并从 .csv 和安全的 .png 中绘制一些数据(国家和项目的订单日期和总利润)
这些是前几行(总共 100k):
Country,Item Type,Order Date,Total Profit
Afghanistan,Baby Food,1/10/2010,672649.62
Afghanistan,Baby Food,1/23/2010,833406.84
Afghanistan,Baby Food,10/14/2011,893894.50
Afghanistan,Baby Food,10/20/2013,38919.16
Afghanistan,Baby Food,11/10/2015,51189.24
Afghanistan,Baby Food,11/19/2014,471247.76
我在 gnuplot 终端中的输入:
set title 'sales'
set xlabel 'date'
set ylabel 'profit'
set datafile separator ','
set xdata time
set timefmt "%m/%d/%y"
plot 100k.csv u 3:4 w lines
如果我在 Gnuplot 终端中使用本手册,它会绘制想要的数据。问题是它没有忽略“标题”(国家、项目类型、订单日期、总利润)
【问题讨论】:
-
你能告诉我们你的剧本吗?从我的立场很难看懂:)
-
你的文件名是什么?将您的文件名放在单引号中。试试
plot '100k.csv' u 3:4 w lines。 -
@Jacques Gaudin 我现在没有任何脚本。我想在编写脚本之前手动绘制它。
-
@theozh 我已经试过了,谢谢 :)
-
grep -q \" youfile.csv && echo quoted输出quoted?
标签: bash csv plot gnuplot script