[Python] What is the best way to loop through a file with python

Discussão em 'Python' iniciado por Stack, Março 24, 2025.

  1. Stack

    Stack Membro Participativo

    I want to search a file for data using python3.

    I have a data file that looks like this (hostname, timestamp, #of CPUs, memory, cpu, disk):

    hostname1,07311906,1,4.84%,74%,0.45%
    hostname2,07311906,2,3.84%,24%,0.45%
    hostname1,07311907,1,4.85%,74%,0.49%
    hostname2,07311907,2,4.64%,44%,0.30%
    hostname1,07311908,1,5.20%,74%,0.78%
    hostname2,07311908,2,4.44%,54%,0.40%


    I'd like to cycle through a config file like this pseudo code:

    for i in server.list do
    <graph the data server i for the month of `date %m`>
    done


    The end goal is loop through my data file and do processing for each server in a list.

    Continue reading...

Compartilhe esta Página