[Python] python dynamic character indexed arrays

Discussão em 'Python' iniciado por Stack, Dezembro 8, 2024.

  1. Stack

    Stack Membro Participativo

    I have a series of files produced each day. Each line has 2 pieces of information city name and rainfall. The file names are day of year.
    For example

    File D2024300 might have
    London 0
    Paris 10
    Sydney 40

    But not each file has the same list of cities. If the city is missing the assumption is it has 0 value.

    I want combine files into a single CSV file with each column being a date. EG
    Table D300 , D301 . D302
    London 0 , 6. 0
    Paris 10 , 25, 0
    Sydney 40 , 60, 0

    I thought about the CSV module but it appears to need numeric indexes whereas I have character indices.
    I have tried dictionaries but adding extra cities on the fly did not work

    I am looking for a relatively efficient method.

    Thanks BZ

    Continue reading...

Compartilhe esta Página