'Parse a YAML like file to CSV
I have a txt file with YAML like syntax. Below is a sample from that. its not fully yaml because there is no colon after DOC ID.
Event Data is :
ID Of Event : {F0B0E47E-0000-CE23-B591-88522468FD33}
Name OF Event : UpdateEvent
Date Created: Thu Feb 10 23:01:50 IST 2022
Event Status: Succeeded
Event SeqNumber: 3.0
DOC Id {80A5E47E-0000-CB1F-BEE6-2402455A10AE}
Source modified object:
Name: sssssssss
Date object modified: Thu Feb 10 23:01:50 IST 2022
Event Data is :
ID Of Event : {F0B0E47E-0000-CE23-B591-88522468FD33}
Name OF Event : UpdateEvent
Date Created: Thu Feb 10 23:01:50 IST 2022
Event Status: Succeeded
Event SeqNumber: 3.0
DOC Id {80A5E47E-0000-CB1F-BEE6-2402455A2AE}
Source modified object:
Name: sssssssss
Date object modified: Thu Feb 10 23:01:50 IST 2022
I need to parse this file and create a CSV file in the below formate
ID Of Event,Name OF Event,Date Created,Event Status,Event SeqNumber,DOC Id ,Source modified object:
F0B0E47E-0000-CE23-B591-88522468FD33,UpdateEvent,Thu Feb 10 23:01:50 IST 2022,Succeeded,3,80A5E47E-0000-CB1F-BEE6-2402455A2AE,"Name: sssssssss, Date object modified: Thu Feb 10 23:01:50 IST 2022"
F0B0E47E-0000-CE23-B591-88522468FD33,UpdateEvent,Thu Feb 10 23:01:50 IST 2022,Succeeded,3,80A5E47E-0000-CB1F-BEE6-2402455A2AE,"Name: sssssssss, Date object modified: Thu Feb 10 23:01:50 IST 2022"
I tried with pyyaml it doesnt work because its not in proper yaml formate. any other options?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
