我将kafka消费者的输出重定向到csv文件,kafka消费者每5秒显示一组记录,如下所示
2020-05-20 20:06:09,2018-01-17 11:29,1.22153,217.81
2020-05-20 20:06:09,2018-01-17 11:30,1.22148,258.97
2020-05-20 20:06:09,2018-01-17 11:31,1.22167,236.62
2020-05-20 20:06:09,2018-01-17 11:32,1.2215,201.3
2020-05-20 20:06:09,2018-01-17 11:33,1.22158,208.42
2020-05-20 20:06:09,2018-01-17 11:34,1.22159,270.86
2020-05-20 20:06:09,2018-01-17 11:35,1.22157,293.05
2020-05-20 20:06:09,2018-01-17 11:36,1.22134,350.72
2020-05-20 20:06:09,2018-01-17 11:37,1.2215,230.86
2020-05-20 20:06:09,2018-01-17 11:38,1.22148,214.04
--- 10 records window ---
--- cycle 2 ---
2020-05-20 20:06:19,2018-01-17 11:39,1.2217,247.39
2020-05-20 20:06:19,2018-01-17 11:40,1.22134,253.39
2020-05-20 20:06:19,2018-01-17 11:41,1.22127,143.59
2020-05-20 20:06:19,2018-01-17 11:42,1.22135,201.36
2020-05-20 20:06:19,2018-01-17 11:43,1.22144,109.34
2020-05-20 20:06:19,2018-01-17 11:44,1.22155,194.18
2020-05-20 20:06:19,2018-01-17 11:45,1.22135,247.14
2020-05-20 20:06:19,2018-01-17 11:46,1.22153,184.07
2020-05-20 20:06:19,2018-01-17 11:47,1.2216,76.84
2020-05-20 20:06:19,2018-01-17 11:48,1.22169,178.06
--- 10 records window ---
我使用下面的命令将输出重定向到csv,它每5秒钟继续将数据附加到csv中
sudo bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test >| file.csv
但是我想要的是,在同一个csv中,每5秒就应该替换(重写)一组现有的记录,应该怎么做?提前谢谢!!
暂无答案!
目前还没有任何答案,快来回答吧!