AHK Read CSV Lines in Text

I want to read a text file that has the chord positions for a song. I need the Chord name, Part, the total beat number for that the chord occurs on and how many beats long until change, so in the chord.txt section below the first A occurs on beat 13 for 8 beats in an A Part.

User will set time signature:
bar_beats = 4 ; this is 4/4 time signature
bar_beats = 3 ; this is 3/4 time signature
[Chords] script reads here [ChordsEnd]
|a) = A part
|b) = B part
|end) = End part
|%| same chord no change for bar
| D| = D chord on beat 1 of the 4 beat bar
| G A| = G chord on beat 1 and A chord on beat 3 of 4 beat bar
|/ CMaj7 / /| = CMaj7 on 2nd beat of the 4 beat bar
|/ / C /| = C on 3rd beat of the 4 beat bar
|/ / / C| = C on 4th beat of the 4 beat bar
if bar_beats = 3
| / G /| = G chord on beat 2 of the 3 beat bar
| A C D C| = A on beat 1 C on beat 2 D on beat 3 C on beat 4
| A C D /| = A on beat 1 C on beat 2 D on beat 3 D on beat 4
All the forward slashes should have spaces, if no space G/C that will be a slash chord (G with a C root) so it's counted as one chord.
Some chord names may have stops or carets C. or C.. or C... or ^^C or ^C
characters may include Cm7b5 Cm7#9 C#m7b5 etc...


|a) D| Gbm7| / / G /| A|%| Gbm| G| A|
|b) Bm| Gbm| G| / D / /| Bm| Gbm| G| A|
|a) D| Gbm| G| A| D| Gbm| G| A|
|b) Bm| Gbm| G| D| Bm| E| G| G A|end) D|

I have this bit that will read the lines between the chord tags, I just need to read each | bar| line and insert the Chord, Part, Beat(total), Length(beats) into the ChordTable and then write that to a text file.

Filename = C:\Temp\chords.txt
FileRead, String, %Filename% 

    If (A_LoopField ~= "Chords]")
        LineNum1 := A_Index
    If (A_LoopField ~= "ChordsEnd")
        LineNum2 := A_Index
MsgBox Start line %LineNum1% End line %LineNum2%
ChordTable := [] 
    if (A_Index > LineNum2 -1)
        break  ; Terminate the loop
    if (A_Index < LineNum1 +1)
        continue ; Skip the below and start a new iteration
        FileReadLine, OutputVar, %Filename%, %A_Index%
        ;Parse line and write to ChordTable Chord Part Beat
        ChordTable[A_Index] := OutputVar 
    MsgBox,  %A_Index% : %OutputVar% 

MsgBox, % ChordTable[3]
How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum