Forum Discussion

JackWren's avatar
JackWren
Helper II
1 year ago

Bulk Upload metadata tables | C# Tabular Editor

Hi, 

 

I have a csv file that contains two columns: tableName and description (that contains the table descriptions)

I'm trying to bulk update my table descriptions. This runs in Tabular but it doesn't load in the dataset. 

using System;
using System.IO;
using System.Linq;

// Define the path to the CSV file
var csvFilePath = @"<ANONYMIZED_PATH>\TableInfo_Test.csv";

// Check if the file exists
if (!File.Exists(csvFilePath))
{
    throw new FileNotFoundException("The specified CSV file was not found.", csvFilePath);
}

// Read all lines from the CSV file
var lines = File.ReadAllLines(csvFilePath);

// Skip the header and parse the CSV file
foreach (var line in lines.Skip(1))
{
    var parts = line.Split(';');

    // Check if the line has at least two parts
    if (parts.Length < 2)
    {
        Console.WriteLine("Skipping line due to insufficient parts: " + line);
        continue; // Skip this line if it doesn't have enough parts
    }

    var tableName = parts[0].Trim();
    var description = parts[1].Trim();

    // Find the table in the model
    var table = Model.Tables.FirstOrDefault(t => t.Name.Equals(tableName, StringComparison.OrdinalIgnoreCase));
    if (table != null)
    {
        Console.WriteLine("Updating table: " + tableName);
        table.Description = description;
    }
    else
    {
        Console.WriteLine("Table not found: " + tableName);
    }
}

 

Did anyone find a solution or something else to do this? 

 

Thank you

 

3 Replies