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

Import from csv files brings wrong data values

(0) ShareShare
ReportReport
Posted on by 157

Hello to everyone.

I have an issue after reading a file from csv. 
The csv has 22 rows, but some of them are empty in some lines and in the container that brings back the data, some values are in wrong position.

for example: 

line 1 : value 1; value2; ; value4; value5

it brings back  :                              [1value1, [2value2, [3value4, [4value5

when it has to bring back              [1value1, [2value2, [3null , [4value4, [5value5

Is it possible to fix this issue somehow?


The code i use to read the file is 

 #File
        container               currentLine;
        int                     totalOfLines;
        CommaTextStreamIo       localStream;
        Num                     number;
            
       
        FileUpload fileUploadControl = this.getFormControl(dialog, FileUploadName);
        
        FileUploadTemporaryStorageResult fileUploadResult = fileUploadControl.getFileUploadResult();
        
        if (fileUploadResult != null && fileUploadResult.getUploadStatus())
        {
            textFile = fileUploadResult.getDownloadUrl();
        }
        
        localStream = CommaTextStreamIo::constructForRead(File::UseFileFromURL(textFile));
        
        
        localStream.inFieldDelimiter("\;");
        localStream.inRecordDelimiter("\n");
    
        currentLine = localStream.read();
        totalOfLines  ;
        
        
        while(currentLine)
        {
            
            number = conPeek(currentLine,1);

            info(strFmt("Number : %1",number));

            currentLine = localStream.read();

        }

I have the same question (0)
  • nmaenpaa Profile Picture
    101,162 Moderator on at

    Hi SGbron,

    what do you mean by "brings back"? What part of your code handles this "bringing back"? Doesn't your code simply print one entry in the infolog for each row in your CSV file?

  • SGbron Profile Picture
    157 on at

    Hello Nikolaos.

    By brings back I mean that in lines:

    while(currentLine)

           {

               number = conPeek(currentLine,1);

               info(strFmt("Number : %1",number));

               currentLine = localStream.read();

           }

    where it reads the file, in the container takes the values that i am writing

    It misses the null value.

  • nmaenpaa Profile Picture
    101,162 Moderator on at

    Could you change your code a bit, to print the contents of currentLine (using con2str(currentLine))?

    And share with us some real CSV rows, and real output from your code? Thanks!

  • Suggested answer
    SGbron Profile Picture
    157 on at

    Finally I found the reason for missing colums.

    I had set the delimeter to ' ; ' but for some reason it doesn't read correct the file when null values exist. the correct delimeter is ' , '.

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
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 429 Most Valuable Professional

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans