Commit 903100a9 authored by Steffen Michels's avatar Steffen Michels

make implementation of readCSVFileWith tail recursive

parent 2d482d53
Pipeline #38062 passed with stage
in 1 minute and 57 seconds
......@@ -72,14 +72,14 @@ readCSVFile :: !*File -> (![[String]],!*File)
readCSVFile file = readCSVFileWith ',' '"' '\\' file
readCSVFileWith :: !Char !Char !Char !*File -> (![[String]],!*File)
readCSVFileWith delimitChar quoteChar escapeChar file
# (mbRec,file) = readCSVRecordWith delimitChar quoteChar escapeChar file
= case mbRec of
Nothing = ([],file)
Just rec
# (recs,file) = readCSVFileWith delimitChar quoteChar escapeChar file
= ([rec:recs],file)
readCSVFileWith delimitChar quoteChar escapeChar file = readCSVFileWithAccum [] file
where
readCSVFileWithAccum :: ![[String]] !*File -> (![[String]],!*File)
readCSVFileWithAccum acc file
# (mbRec, file) = readCSVRecordWith delimitChar quoteChar escapeChar file
= case mbRec of
Nothing = (reverse acc,file)
Just rec = readCSVFileWithAccum [rec: acc] file
writeCSVRecord :: ![String] !*File -> *File
writeCSVRecord fields file = writeCSVRecordWith ',' '"' '\\' fields file
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment