Commit 8c355c3c authored by Camil Staps's avatar Camil Staps 🐧

Merge branch 'tailRecReadCsvFileWith' into 'master'

make implementation of readCSVFileWith tail recursive

See merge request !305
parents 2d482d53 903100a9
Pipeline #38467 passed with stage
in 1 minute and 58 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