Module Text.CSV

Library for reading/writing files in CSV format. Files in CSV (comma separated values) format can be imported and exported by most spreadsheed and database applications.

Author: Michael Hanus

Version: September 2004

Summary of exported operations:

writeCSVFile :: String -> [[String]] -> IO ()  Deterministic 
Writes a list of records (where each record is a list of strings) into a file in CSV format.
showCSV :: [[String]] -> String  Deterministic 
Shows a list of records (where each record is a list of strings) as a string in CSV format.
readCSVFile :: String -> IO [[String]]  Deterministic 
Reads a file in CSV format and returns the list of records (where each record is a list of strings).
readCSVFileWithDelims :: String -> String -> IO [[String]]  Deterministic 
Reads a file in CSV format and returns the list of records (where each record is a list of strings).
readCSV :: String -> [[String]]  Deterministic 
Reads a string in CSV format and returns the list of records (where each record is a list of strings).
readCSVWithDelims :: String -> String -> [[String]]  Deterministic 
Reads a string in CSV format and returns the list of records (where each record is a list of strings).

Exported operations:

writeCSVFile :: String -> [[String]] -> IO ()  Deterministic 

Writes a list of records (where each record is a list of strings) into a file in CSV format.

Example call:
(writeCSVFile fname rows)
Parameters:
  • fname : the name of the result file (with standard suffix ".csv")
  • rows : the list of rows

showCSV :: [[String]] -> String  Deterministic 

Shows a list of records (where each record is a list of strings) as a string in CSV format.

readCSVFile :: String -> IO [[String]]  Deterministic 

Reads a file in CSV format and returns the list of records (where each record is a list of strings).

Example call:
(readCSVFile fname)
Parameters:
  • fname : the name of the result file (with standard suffix ".csv")

readCSVFileWithDelims :: String -> String -> IO [[String]]  Deterministic 

Reads a file in CSV format and returns the list of records (where each record is a list of strings).

Example call:
(readCSVFileWithDelims delims fname)
Parameters:
  • delims : the list of characters considered as delimiters
  • fname : the name of the result file (with standard suffix ".csv")

readCSV :: String -> [[String]]  Deterministic 

Reads a string in CSV format and returns the list of records (where each record is a list of strings).

Example call:
(readCSV str)
Parameters:
  • str : the string in CSV format

readCSVWithDelims :: String -> String -> [[String]]  Deterministic 

Reads a string in CSV format and returns the list of records (where each record is a list of strings).

Example call:
(readCSVWithDelims delims str)
Parameters:
  • delims : the list of characters considered as delimiters
  • str : the string in CSV format