Simple Monkey language CVS parser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Method Parse() ' csv parser | |
Local _inc:Bool = False | |
Local afc:Bool = False | |
Local quote:=New Quote | |
Local c:String, c1:String = "" | |
raw = raw + "~n" ' make sure we catch the last one | |
For Local i := 0 To raw.Length | |
c = raw[i..i+1] | |
If i+2 < raw.Length | |
c1 = raw[i+1..i+2] | |
Else | |
c1 = "" | |
End | |
If c = "~n" ' done with this one | |
If quote.quote.Trim().Length > 0 And quote.movie.Trim().Length > 0 | |
quotes.AddLast(quote) | |
afc = False | |
quote = New Quote | |
End | |
Else If c = "," And Not _inc ' , but not in " | |
afc = True | |
Else If c = "~q" And c1 <> "~q" | |
_inc = Not _inc | |
Else | |
If afc | |
quote.movie = quote.movie + c | |
Else | |
quote.quote = quote.quote + c | |
End | |
End | |
End | |
End |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment