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)

reading string from csv file

(0) ShareShare
ReportReport
Posted on by 240

Hi all,

I have the requirement as follows.

I will be reading values from csv file which will look similar to below.

A    B    C

1    (5)   5
(2)  (3)  (8)

2    (1)   8

when the file is opened through ms excel the values in the bracket are getting converted as -5,-2-3-8 and -1. But when i open it with notepad the values are as follows 1,(5),5,(2),(3),(8),2,(1),8.

The requirement now is i should read the csv file and populate the values to table. When i use the str2num method to read the values i'm getting the values as 0 which are inside the bracket. When i populate the table the values that are inside the bracket should be inserted as e.g if i read (5) then the value should be inserted as -5 in the table.


And also can you tell me why i'm getting correct values in ms excel i.e as -5 for (5) and not getting same result in notepad or notepad++.

Thanks.

*This post is locked for comments

I have the same question (0)
  • XB Profile Picture
    1,875 on at

    Which class are you using to open csv?

    If you use excel class can convert cell.

    Example:

    WorkSheet.cells().range("A1").numberFormat("0,00%"); //Format as %

  • venkates Profile Picture
    240 on at

    commaio class is used to read the values from the csv.

  • Verified answer
    XB Profile Picture
    1,875 on at

    I'm not sure if exist a better option but you always could try this

    static void Job180(Args _args)

    {

       str value = '(5)';

       str newvalue;

       int num;

       newValue = strRem(value, ')');

       newValue = strReplace(newValue, '(', '-');

       num = str2num(newvalue);

       info(strFmt("%1", num));

    }

  • venkates Profile Picture
    240 on at

    it is working. but is there any shorter code to do this.

  • Community Member Profile Picture
    on at

    Create a function(method) with the code provided by Javier Biesa 

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