Last active
August 5, 2023 07:37
-
-
Save chuongmep/98a66df258667ac3ba3f0ab2684979f5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using ParquetSharp; | |
void Main() | |
{ | |
SaveToParquet(); | |
} | |
public static void SaveToParquet() | |
{ | |
var objectIds = new Entity[3]; | |
objectIds[0] = new Entity { Id = 1, ElementId = 1 }; | |
objectIds[1] = new Entity { Id = 2, ElementId = 2 }; | |
objectIds[2] = new Entity { Id = 3, ElementId = 3 }; | |
var columns = new ParquetSharp.Column[] | |
{ | |
new Column<int>("Id"), | |
new Column<int>("ElementId"), | |
}; | |
string path = @"C:\Users\vho2\OneDrive - Exyte\Documents\LINQPad Queries\float_timeseries.parquet"; | |
using var file = new ParquetFileWriter(path, columns); | |
using var rowGroup = file.AppendRowGroup(); | |
using (var timestampWriter = rowGroup.NextColumn().LogicalWriter<int>()) | |
{ | |
timestampWriter.WriteBatch(objectIds.Select(x => x.Id).ToArray()); | |
} | |
using (var timestampWriter = rowGroup.NextColumn().LogicalWriter<int>()) | |
{ | |
timestampWriter.WriteBatch(objectIds.Select(x => x.ElementId).ToArray()); | |
} | |
file.Close(); | |
Console.WriteLine("Done"); | |
} | |
public class Entity | |
{ | |
public int Id { get; set; } | |
public int ElementId { get; set; } | |
} | |
// You can define other methods, fields, classes and namespaces here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment