Aller au contenu

darklite44

Membres confirmés
  • Compteur de contenus

    447
  • Inscription

  • Dernière visite

  • Jours gagnés

    1

Community Answers

  1. darklite44's message in Telechargement Csv En Lua was marked as the answer   
    Prise en compte des dates après la dernière facture réalisée (2015-04-05) :
    local LastBill =os.time{year=2015, month=04, day=05} if (not tcpSERVER) then   fibaro:debug("SERVER ERROR! Skipping..."); else   fibaro:debug("---");   size, content  = getFileFromServer(tcpSERVER, "/protect/download/xdata.csv");   if (size>0) then fibaro:debug("Received file [" .. size .. " bytes]."); fibaro:debug("content [" .. content .. "]."); local table = split(content, "\n"); if(not l)then l=0; end      for i,j in pairs(table)do -- test du pattern annee, mois, jour, hp, hc = j:match("(%d+),(%d+),(%d+),%d+,(%d+),(%d+),"); if(annee) then          local seconds = os.time{year=annee, month=mois, day=jour}; local diff = tonumber(os.difftime(seconds, LastBill)); -- insertion dans le tableau       day = annee .. "-" .. mois .. "-"  .. jour       f_day = format_date(day, "dd/mm/yy");       if(diff > 0) then           energylist[#energylist + 1] = { date = f_day, hp = hp, hc = hc }           fibaro:debug("date=" .. f_day .. ", HP:" .. hp .. ", HC:" .. hc .. ", sec_diff=" .. diff);           end             end       end fibaro:debug("DONE!");   else     fibaro:debug("Connection problem!");   end end  
    Ce qui donne dans le debug: [DEBUG] 16:28:27: Received file [7988 bytes]. [DEBUG] 16:28:27: date=06/04/15, HP:1325477, HC:1050730, sec_diff=86400 ... [DEBUG] 16:28:27: date=19/04/15, HP:1432648, HC:1135514, sec_diff=1209600 [DEBUG] 16:28:27: DONE!
×
×
  • Créer...