Notifications
Announcements
No record found.
When the csv file is created, the information is displayed on a single line. How could I write the code so that it splits into distinct columns?
[embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:3bf00c73-fb7e-4568-95d3-353303ba1693:type=text&text=%20%20%20%23File%0D%0A%20%20%20%20PurchTable%20purchTable%3B%0D%0A%20%20%20%20LogisticsPostalAddress%20logisticsPostalAddress%3B%0D%0A%20%20%20%20PurchLine%20purchLine%2C%20purchLineReceived%3B%0D%0A%20%20%20%20InventDim%20inventDim%3B%0D%0A%20%20%20%20PDSAdvancedPriceInfo%20pdsAdvancedPriceInf%3B%0D%0A%20%20%20%20PI_ReceivedStatus%20receivedStatus%3B%0D%0A%20%20%20%20PI_FullyInvoiced%20fullyInvoiced%3B%0D%0A%20%20%20%20PurchLine%20purchStatus%3B%0D%0A%20%20%20%20InventTrans%20inventTrans%3B%0D%0A%20%20%20%20InventTransOrigin%20inventTransOrigin%3B%0D%0A%20%20%20%20int%20delays%3B%0D%0A%20%20%20%20date%20d%20%3D%20today%28%29%3B%0D%0A%0D%0A%20%20%20%20CommaTextIo%20file%3B%2F%2F%0D%0A%20%20%20%20container%20line%3B%2F%2F%0D%0A%20%20%20%20FileIoPermission%20perm%3B%2F%2F%0D%0A%20%20%20%20FileName%20fileName%3B%2F%2F%0D%0A%20%20%20%20%3B%0D%0A%0D%0A%20%20%20%20filePath%3D_dataContract.parmFilePath%28%29%3B%0D%0A%20%20%20%20fileName%3D%20filePath%20%2B%20%22%5C%5CEX.csv%22%3B%0D%0A%20%20%20%20perm%20%3D%20new%20FileIoPermission%28fileName%2C%20%23io_write%29%3B%0D%0A%20%20%20%20perm.assert%28%29%3B%0D%0A%0D%0A%20%20%20%20file%20%3D%20new%20CommaTextIo%28fileName%2C%20%23io_write%29%3B%0D%0A%20%20%20%20if%20%28%21file%20%7C%7C%20file.status%28%29%20%21%3D%20IO_Status%3A%3AOk%29%0D%0A%20%20%20%20%7B%20%20%20%0D%0A%20%20%20%20%20%20%20%20throw%20error%28%22File%20cannot%20be%20opened.%22%29%3B%0D%0A%20%20%20%20%7D%0D%0A%20%20%20%20%20%20%20%20file.outRecordDelimiter%28%27%5Cr%5Cn%27%29%3B%0D%0A%20%20%20%20%20%20%20%20file.outFieldDelimiter%28%27%2C%27%29%3B%0D%0A%20%20%20%20%20%20%20%20file.write%28strFmt%28%27%251%3B%252%3B%253%3B%254%3B%255%3B%256%3B%257%3B%258%3B%259%3B%2510%3B%2511%3B%2512%3B%2513%3B%2514%3B%2515%3B%2516%3B%2517%27%2C%22Vendor%20account%22%2C%22Vendor%20name%22%2C%22Vendor%20group%22%2C%22Delivery%20address%22%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Received%20status%22%2C%22Fully%20invoiced%22%2C%22Line%20number%22%2C%22Item%20number%22%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Product%20name%22%2C%22Site%22%2C%22Warehouse%22%2C%22Quantity%22%2C%22Unit%20price%22%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Net%20amount%22%2C%22Confirmed%20delivery%20date%22%2C%22Delays%22%2C%22Line%20status%22%29%29%3B%0D%0A%0D%0A%20while%20select%20purchTable%0D%0A%20%20%20%20%20%20%20%20where%20purchTable.OrderAccount%3D%3D_dataContract.parmVendAccount%28%29%20%7C%7C%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20purchTable.VendGroup%3D%3D_dataContract.parmVendGroup%28%29%0D%0A%20%20%20%20%20%20%20%20%26%26%20purchTable.DeliveryDate%20%3E%3D%20_dataContract.parmFromDate%20%28%29%0D%0A%20%20%20%20%20%20%20%20%26%26%20purchTable.DeliveryDate%20%3C%3D%20_dataContract.parmToDate%20%28%29%20%26%26%0D%0A%20%20%20%20%20%20%20%20purchTable.PurchStatus%21%3DPurchStatus%3A%3ACanceled%0D%0A%20%20%20%20%20%20%20%20join%20logisticsPostalAddress%0D%0A%20%20%20%20%20%20%20%20where%20purchTable.DeliveryPostalAddress%3D%3DlogisticsPostalAddress.RecId%0D%0A%20%20%20%20%20%20%20%20join%20%20purchLine%0D%0A%20%20%20%20%20%20%20%20where%20purchLine.PurchId%3D%3DpurchTable.PurchId%0D%0A%20%20%20%20%20%20%20%20join%20inventDim%0D%0A%20%20%20%20%20%20%20%20where%20purchLine.InventDimId%3D%3DinventDim.InventDimId%0D%0A%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%20if%20%28purchTable.PurchStatus%3D%3DPurchStatus%3A%3AReceived%20%7C%7C%20purchTable.PurchStatus%3D%3DPurchStatus%3A%3AInvoiced%29%0D%0A%20%20%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20receivedStatus%3DPI_ReceivedStatus%3A%3AFullyReceived%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20line%3D%5BstrFmt%28%27%251%3B%252%3B%253%3B%254%3B%255%27%2CpurchTable.OrderAccount%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20purchTable.PurchName%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20purchTable.VendGroup%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20logisticsPostalAddress.Address%2Cenum2str%28receivedStatus%29%29%5D%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%0D%0A%20%20%20%20%20%20%20%20%7D%0D%0A%20%20%20%20%20%20%20%20%0D%0A%20%20%20%20%20%20%20%20file.writeExp%28line%29%3B%0D%0A%20%20%20%20%7D%0D%0A%0D%0A%20%20%20%20%20%20CodeAccessPermission%3A%3ArevertAssert%28%29%3B%0D%0A%20%20%20%20%20%20if%28WinApi%3A%3AfileExists%28fileName%29%29%0D%0A%20%20%20%20%20%20%20%20%20%20%20WinApi%3A%3AdeleteFile%28fileName%29%3B%0D%0A%20%20%20%20%20%20WINAPI%3A%3AshellExecute%28fileName%29%3B%0D%0A%20%20%20%20%20%20return%20%22Completed%22%3B%0D%0A%20%20%20%20%20]
You're asking a wrong question. There is nothing wrong with the file - you problem is in how Excel interprets it by default. Note that CSV is a text file; it's not an Excel spreadsheet.
In Excel, use Data > Get Data > From File > From Text/CSV and configure the import according to your needs.
If you're free to change the format and you want your Excel to open the file in the expected way by default, try using a different column delimiter, and maybe using quotation marks around values. Experiment with the format (using a text editor) and starting changing code when you know what you want to generate.
Hi Pavel,
Refer to the below thread. Same issue is already discussed in the below thread.
https://community.dynamics.com/ax/f/microsoft-dynamics-ax-forum/150846/csv-creation-from-textio-not-creating-true-csv
Thanks,
Girish S.
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Martin Dráb 551 Most Valuable Professional
André Arnaud de Cal... 450 Super User 2025 Season 2
BillurSamdancioglu 278 Most Valuable Professional