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 :
Microsoft Dynamics AX (Archived)

Append line to an existing csv file

(0) ShareShare
ReportReport
Posted on by

Hi All,

I want to open an existing csv file and append record/line to it from AX 2012 Job. Every time I am trying to do that it is replacing the file with new set of record.

Please advice.

Thanks and Regards,

Arindam

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    237,795 Most Valuable Professional on at

    Let's start with an example:

    #File
    CommaTextIo io = new CommaTextIo(@'c:\temp\test.csv', #io_append);
    ;
    io.write("abcd", 123);

    You can run this code several times and it always add another line to the file.

    The second parameter of CommaTextIo's constructor is crucial - if you use #io_write (or 'w') instead, the existing file content will be overwritten.

     

  • Community Member Profile Picture
    on at

    Hi Martin,

    It worked. thank you. I was using #io_write. In that way every time it was creating a new file and line. Now after using #io_append I am getting desired out put.

    Thank you.

    Regards,

    Arindam

  • Community Member Profile Picture
    on at

    Hi Martin,

    I have to do the same for all the files which are in one particular folder,how can mention the path to do the same.

    Can you please suggest.

  • Community Member Profile Picture
    on at

    Adding to the previous .. I have  6 columns in CSV, for 5th column  last row I need to add the particular Text.

    How to mention the particular column and last row, please suggest if any?

    Thanks

    Hari

  • Martin Dráb Profile Picture
    237,795 Most Valuable Professional on at

    If you have more files, you'll use the same, just several times (once for each file).

    The other question isn't related to the topic of this thread ("Append line to an existing csv file"); please create a new one (with an appropriate title and tags) and explain your problem there.

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans