Search code examples
csvf#deedle

F# read zipped csv file


is that possible to use F# deedle to read zipped csv directly like the read_csv function in pandas? if this is not possible, is that possible to use csv type provider to do this ?


Solution

  • If you use the ICSharpCode.SharpZipLib NuGet package, you can read the CSV from the zip with Deedle like this:

    open ICSharpCode.SharpZipLib.Zip
    open System.IO
    open Deedle
    
    [<EntryPoint>]
    let main argv = 
        use fs = new FileStream(@"mycsv.zip", FileMode.Open, FileAccess.Read)
        use zip = new ZipFile(fs)
        use csv = zip.GetInputStream(0L)
        let frame = Frame.ReadCsv(csv)