I have a dynamic csv/tsv file (tab delimiter) where a new row is added underneath Debit Count and Score Count every hour. No new rows will be added under Receipt Count, only the value changes each hour. Please see two examples below for reference.
Example of FileA.csv at the 3rd hour
Debit Count VALUE
hour 1 5
hour 2 81
hour 3 15
Score Count
hour 1 31
hour 2 66
hour 3 9
Receipt Count
age logs 23
bus logs 21
pig logs 7
dog logs 40
Example of FileA.csv at the 7th hour
Debit Count VALUE
hour 1 5
hour 2 81
hour 3 15
hour 4 20
hour 5 52
hour 6 33
hour 7 35
Score Count
hour 1 31
hour 2 66
hour 3 9
hour 4 112
hour 5 15
hour 6 38
hour 7 21
Receipt Count
age logs 13
bus logs 28
pig logs 85
dog logs 55
So what i'm trying to achieve is separate FileA.csv into ABC.csv , DEF.csv and GHI.csv keeping in mind that the rows underneath Debit Count and Score Count increases every hour. The new files ABC.csv,DEF.csv,GHI.csv will be REPLACED every hour
Using the 3rd hour example for reference to what i'm trying to achieve
ABC.csv
Debit Count VALUE
hour 1 5
hour 2 81
hour 3 15
DEF.csv
Score Count
hour 1 31
hour 2 66
hour 3 9
GHI.csv
Receipt Count
age logs 23
bus logs 21
pig logs 7
dog logs 40
What I tried doing (Edited)
awk f="ABC.csv DEF.csv GHI.csv" '
BEGIN {split(f,files)} /^Debit/ /^Score/ /^Receipt/ {n++} {print>files[n]}' FileA.csv
This question was closed for lack of focus in a previous post and i was given the option to either edit or re-post the question. I decided to re-post the question with better clarity so others that may have seen it before could see it again. Thanks