I've got script to read data from Arduino and save it as TXT file. I also have script to separate data and to add date/time, than save in new TXT file.
I've got also few Cron scripts like:
- Read temeprature every 1 minute and save as TXT file (Script 1)
- Read temperature every 10 minutes and save as TXT file (Script 2)
- Read temperature every 60 minutes and save as TXT file (Script 3)
I would like to make a few charts:
- Temperature in last hour
- Temperature in last 3 hours
- Temperature in last 12 hours
- Temperature in last 24 hours
- Temperature in last 7 days
So I need new Python script to:
Get last 60 lines from Script 1 - save it as new TXT file, to use it as chart "Temperature in last hour"
Get last 18 lines from Script 2 - save it as new TXT file, to use it as chart "Temperature in last 3 hours"
Get last 72 lines from Script 2 - save it as new TXT file, to use it as chart "Temperature in last 12 hours"
Get last 144 lines from Script 2 - save it as new TXT file, to use it as chart "Temperature in last 24 hours"
Get last 168 lines from Script 3 - save it as new TXT file to use it as chart "Temperature in last 7 days"
Can you help me to write simple script for example to get last 60 lines from FILE.txt and save them as FILE2.txt ? I will edit it for next scripts I need.
EDIT: I probbably know how to keep my chart files sized as I want (60 lines), but now I would like to ask is it possible to make any script, who will delete FIRST 30 lines?
I have only about 1 GB space, so I need to clean TXT files ;) If I will get temperature every minute after two weeks It will full my hard drive ;)
So I think CRON action to delete first X lines from txt file can help me a lot. Do you know any script?
If I will get it, I will finally finish my master project and ofcourse I will show you results :)