Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Suggested answer

Import CSV file

Posted on by Microsoft Employee

Hi  all,

I am wrote a excel import job to bulk update the customer addresses  while reading the data from csv sometimes garbage values like ??? and ,,,, are getting inserted in to the table where I am storing the data. How can we avoid reading of these garbage values.

  • Suggested answer
    DynamicsAXAbdu Profile Picture
    DynamicsAXAbdu 205 on at
    RE: Import CSV file

    And I do totally agree with Martin

    Consider using the data import/export framework for such a task.

    And if you're really keen on your own code - please debug it.

    Regards,

    Abdullah

  • Suggested answer
    DynamicsAXAbdu Profile Picture
    DynamicsAXAbdu 205 on at
    RE: Import CSV file

    Please double check your csv format.

    pastedimage1608273083201v1.png

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Import CSV file

    DirParty                    dirParty;
        DirPartytable               dirPartytable,dirPartyTable_P;
        LogisticsLocation           logisticsLocation,logisticsLocation1,logisticsLocation_P;
        LogisticsLocationRole       locationRole,logisticsLocationRole,logisticsLocationRole_P;
        Args args = new Args();
        DocuRef         docRef;
        container   roles,readCon;
        counter     icount,inserted;
        int recCount =0,fvalid=0;
        csvFile = new CommaIO(filename, 'r');
        try
        {
            if (csvFile)
            {
                readCon = csvFile.read();
                while (csvFile.status() == IO_Status::OK)
                {
                    readCon = csvFile.read();
                    fvalid  ;
                    if(readCon)
                    {
                        icount  ;
                        if( !conPeek(readCon,1) && !conPeek(readCon,2) && !conPeek(readCon,3)
                            && !conPeek(readCon,4) && !conPeek(readCon,5) && !conPeek(readCon,6)
                            && !conPeek(readCon,7) && !conPeek(readCon,8) && !conPeek(readCon,9)
                            && !conPeek(readCon,10))
                            break;
                        iAccountNum  = conPeek(readCon,1);

    In the Line number 28 container is reading the account number with garbage values .

  • Suggested answer
    DynamicsAXAbdu Profile Picture
    DynamicsAXAbdu 205 on at
    RE: Import CSV file

    Hi mahiim,

    Can you please share your code? and also double-check the format in your CSV file

    Please check this as well https://www.schweda.net/blog_ax.php?bid=573&wdl=en

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Import CSV file

    while my import job reading values from csv file in to container it is reading the values along with garbage values.

    For example:

    I have account number :0000004 in my excel file but when reading the value in to the container it is reading line ???0000004

  • Martin Dráb Profile Picture
    Martin Dráb 230,235 Most Valuable Professional on at
    RE: Import CSV file

    You can avoid such bugs by not writing any code at all. Consider using the data import/export framework already included in AX 2012, which can import both Excel and CSV files without such issues.

    If you insists on spending time with your own code anyway, use the debugger to find out where it doesn't behave as intended. If you fail to understand why, share the code together with input values and tell us what's wrong with it.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans