-2

I want to write a CSV File which gets Data from and depending from an existing CSV File.

Existing_FILE:

Date, Value, Name, sh
2022-01-15, 30,00, Monthly1 - #1500, H
2022-01-18, 130,00, Monthly50, S
2022-01-24, 344,00, Bill # 1110 .. blabla, S

New_CSV

Date, Name, Name2, Value
2022-01-15, fee, Marcus, +30,00
2022-01-18, rent, Oliver, -130,00
2022-01-24, Bill # 110, , -344,00

There is many Rules which applay to the existing Data to create the new File. I just wonder which is the best Approach.

Right now I open the existing CSV and write everything to a named Tuple. I think best idea is to write the new CS to a namedTuple array again? So the Coding is clean and selfdescribing?

Would be nice if someone could light me up with a cool solution.

Thx in advance.

JNevill
  • 46,980
  • 4
  • 38
  • 63

1 Answers1

0

You might like the native DictWriter module: https://docs.python.org/3/library/csv.html#csv.DictWriter

It's far easier than using NamedTuple.

loki.dev
  • 172
  • 6