web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

How to skip header of each csv file while inserting data into ax table from a local folder

(0) ShareShare
ReportReport
Posted on by 141
I have the same question (0)
  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    The code that you refer to reads all lines starting from the first line (while this.readLine()).

    So all you need to do is to not call processRow in the first iteration of that while loop for each file.

  • Sohaib Cheema Profile Picture
    49,438 User Group Leader on at

    another thing you can make code to start reading from row 2 instead of 1. I can understand you have headers on top row of the file.

  • community Profile Picture
    141 on at

    I tried many ways but it still copy the header for next file.

  • community Profile Picture
    141 on at

    i tried but nothing happened

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    We could try to spot what's wrong with your code, but you forgot to share it..

    Anyway, let's take the code from the blog and demostrate. I added new variable currentRowInFile to handle the requirement of skipping the first row of each file:

    private void
    readFilesFromDirtecory()
    {
    
        SetEnumerator           sE;
        int                     row = 1;
    
        filePath = @"C:\Temp\FilesToRead";
    
        this.getFiles();
    
        sE = fileSet.getEnumerator();
    
        while (sE.moveNext()) // loop through all files
        {
            int currentRowInFile = 1;
            filename = sE.current();
    
            this.openFile();
    
            while(this.readLine())
            // loop through all lines from current file
    
            {
                if (currentRowInFile > 1)
                {
                    this.processRow(row, lineCon);
                }
    
                currentRowInFile  ;
                row  ;
            }
        }
    }
    

    Is it now clear? If not, please share your code so that we can help with it.

  • André Arnaud de Calavon Profile Picture
    301,053 Super User 2025 Season 2 on at

    Hi Marian,

    What exact product are you using? You shared a blog related to AX2012, but posted the question in the Dynamics 365 forum.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 559 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 464 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans