拆分 csv 文件:每天一个记录文件
我有一个文件Metrics.csv
包含来自不同传感器的几行记录。这是每行的标题和格式:
name,time,HMDT,LUMI,TEMP,id,location,type
metrics,1587529745754514305,,9,,24a89ddc-23c8-4d9f-9f5e-cff4eba32fb5,school,sensors
metrics,1587529745954605110,,,25.7,88cb0522-478a-456c-b63b-9c402b5e03b2,school,sensors
...
时间是在纳秒中给出的时间(我乘以前10位将其转换为日期)。 我想每天创建一个文件。 到目前为止,我做了这个循环,它使我可以访问每条线的日期:
#!/bin/bash
while IFS=, read -r name time HMDT LUMI TEMP id location type
do
date -d @${time::10}
done < metrics.csv
感谢您的帮助,我是Bash的初学者。 非常感谢。
I have a file metrics.csv
containing several lines of records from different sensors. Here is the header and the format of each line :
name,time,HMDT,LUMI,TEMP,id,location,type
metrics,1587529745754514305,,9,,24a89ddc-23c8-4d9f-9f5e-cff4eba32fb5,school,sensors
metrics,1587529745954605110,,,25.7,88cb0522-478a-456c-b63b-9c402b5e03b2,school,sensors
...
The time is given in nanoseconds (I take the first 10 bits in order to convert it to a date).
I would like to create one file per day.
Up to now, I did this loop, which allows me to access to the date of every line :
#!/bin/bash
while IFS=, read -r name time HMDT LUMI TEMP id location type
do
date -d @${time::10}
done < metrics.csv
I would appreciate your help, I am a beginner in bash.
Many thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是我的解决方案:
Here is my solution :