Article wisitsak sangiamsak · Jul 31, 2025 1m read

Here's a practical example of how to import data from a CSV file into InterSystems CACHÉ using ObjectScript
Assuming your CSV file is simple (e.g., comma-separated, with headers), you can use %Stream.FileCharacter to read it line by line and parse the data.
 

ClassMethod ImportCSV(filePath As %String) As %Status {
    Set stream = ##class(%Stream.FileCharacter).%New()
    Set sc = stream.LinkToFile(filePath)
    If 'sc Quit sc

    While 'stream.AtEnd {
        Set line = stream.ReadLine()
        Set fields = $ListFromString(line, ",")
        // Example: Save to a persistent class
        Set obj =

0
0 116