Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

How to Import CSV file by removing the header column

(0) ShareShare
ReportReport
Posted on by

I am trying to import a csv file through xml port, I Need to remove the header column , how is it possible , any help will be great,Thanks

  • Elijah Stownton Profile Picture
    192 on at
    RE: How to Import CSV file by removing the header column

    Another option to import CSV to Dynamics is to use Skyvia. It is a no code SaaS.

  • Community Member Profile Picture
    on at
    RE: How to Import CSV file by removing the header column

    Thank you Nitin Verma  it helped

  • Verified answer
    Nrims Profile Picture
    50 on at
    RE: How to Import CSV file by removing the header column

    Hey !

    I'v got the same issue recently and i found a solution.

    The goal is to initialize a boolean variable and to execute it only once.

    In the xmlport we create an OnPreXmlPort trigger which initializes the variable to true.

    Then in the table we create the OnAfterInitRecord trigger which executes the variable only once and which will use the currXMLport.Skip() function which allows to ignore the first line of the CSV file, the header.

    Exemple:

    xmlport ID "Name"
    {
        Format = VariableText;
        Direction = Import;
        UseRequestPage = false;
    
        schema
        {
            textelement(Root)
            {
                tableelement("Import CSV Table"; "Import CSV Table")
                {
                    XmlName = 'Import';
    
                    fieldelement("Something"; "Table"."Something")
                    {
                    }
                    fieldelement(Date; "Table".Date)
                    {
                    }
                    fieldelement(Type; "Table".Type)
                    {
                    }
    
                    trigger OnAfterInitRecord()
                    begin
                        if firstline then begin
                            firstline := false;
                            currXMLport.Skip();
                        end;
                    end;
                }
            }
        }
        var
            firstline: Boolean;
        // Initialize the flag on pre-xmlport event
        trigger OnPreXmlPort()
        begin
            firstline := true;
        end;
    }

  • Suggested answer
    Nitin Verma Profile Picture
    21,565 Moderator on at
    RE: How to Import CSV file by removing the header column

    Hi,

    try as per below on Onbeforeinsertrecord() trigger

    if GlobalVar = 0 then

     currXMLport.SKIP;

    GlobalVar += 1 ;

    declare globalVar as global variable as Integer

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard >

Featured topics

Product updates

Dynamics 365 release plans