Search by date in txt file

Asked

Viewed 35 times

0

Hey, guys. If anyone can help me, I need to get values from one date to the next in a txt file. That is, the user puts the start and end date, and the values of those dates are returned. If anyone can help me do that, I’m grateful! bjs

I already have this (relevant part of the code), here I am getting the value that interests me in the file. So I’d like to take a specific date, and the corresponding value. I am creating a chart with these values. Hence what I need to do: assemble another one with the values of the date that the user wants. I’m sorry if I’m misquoted

A file line:

9/1/17,6:50:06 PM,INVALID,0.0,INVALID,0.0,INVALID,0.0,INVALID,0.0,INVALID,0.0,VALID,920.221,VALID,920.221,VALID,920.221,VALID,0.0,VALID,0.0,VALID,2.4,VALID,-500.0,VALID,VALID,500.0,VALID,500,0,0,INVALID, - VALUE NOT AVAILABLE,0.0,VALID,811.697,VALID,811.697,VALID,811.697,INVALID - VALUE NOT AVAILABLE,0.0,INVALID,0.0,INVALID,0.0,INVALID,0.0,INVALID - VALUE NOT AVAILABLE,0.0,INVALID,0.0,INVALID,0.0,INVALID,0.0,INVALID - VALUE NOT AVAILABLE,0.0,VALID,0.0,VALID,0.0,VALID,0.0,INVALID - VALUE NOT AVAILABLE,0.0,INVALID,360.0,INVALID,360.0,INVALID,360.0,INVALID,0.0,INVALID,0.0,INVALID,0.0, - VALUE NOT AVAILABLE,0.0,VALID,34.947,

$arquivo = fopen('graficoItaguacu/arquivo.txt','r');
$dataPoints_umidade = array();
function processaLinha_umidade($linha_umidade){
    global $dataPoints_umidade;
    list($data, $hora,$tempSt, $tempAvg, $tempSt2, $tempMax, $tempSt3, $tempMin, $umiSt, $umiAvg, $umiSt2, $umiMax, $umiSt3, $umiMin,$pressSt, $pressAvg, $pressSt2, $pressMax, $pressSt3, $pressMin,$precipSt1, $precipPP, $precipSt2, $precipPPMensal,$radLiqSt1, $radLiqAvg, $radLiqSt2, $radLiqMax, $radLiqSt3, $radLiqMin, $radLiqSomaSt, $radLiqSomaSum,$radGl1St1, $radGl1Avg, $radGl1St2, $radGl1Max, $radGl1St3, $radGl1Min, $radGl1SomaSt, $radGl1SomaSum,$radGl2St1, $radGl2Avg, $radGl2St2, $radGl2Max, $radGl2St3, $radGl2Min, $radGl2SomaSt, $radGl2SomaSum,$radDif2St1, $radDif2Avg, $radDif2St2, $radDif2Max, $radDif2St3, $radDif2Min, $radDif2RD3SomaSt, $radDif2RD3SomaSum,$radUVSt1, $radUVAvg, $radUVSt2, $radUVMax, $radUVSt3, $radUVMin, $radUVSomaSt, $radUVSomaSum,$dvSt1, $dvDirAvg, $dvSt2, $dvGusDir, $dvSt3, $dvLullDir, $dvSt4, $dvSpdAvg, $dvSt5, $dvSpdMax, $dvSt6, $dvSpdMin,$chargerSt1, $chargerExter,$intSt1, $intT) = explode(",", $linha_umidade);

    array_push($dataPoints_umidade, array("x" => date_timestamp_get(date_create_from_format('m/d/y g:i:s a', "${data} ${hora}"))*1000,"y" => $umiAvg));
}
while ($linha_umidade = fgets($arquivo)) {
  processaLinha_umidade($linha_umidade);
}
  • And what is the file? What are the date formats? What have you done? What was the result obtained? What was difficult for you?

  • Post at least the file format and what you’ve tried. It’s easier to help

  • The file is txt, m/d/a, I have already processed the file, I am trying to input to get the start date and another to get the end date, but I need to do this in php. The difficulty is just this... Hence what I thought: receive the date in a variable, and compare with the file date, all within a loop.

  • Still it is not possible to help you. Edit your question with the TXT format and the code you already have working

  • It was poorly explained ne? kk sorry.. Even if you can’t help me, thank you for your attention

  • Already solved the problem! if anyone wants to know how I did tell me I’m in charge here.

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.