How to read a row longer than 1024 lenth from a csv file?

gisongison Member Posts: 128
Dear all,
I'm trying to read a csv file and import into Navision... but the problem is the vairable:g_txtProcessingLine have 1024 length limitation.
The row in the csv file is possible more then 1024 length, does anyone know how to deal with it? I'm trying to study how to use bigtext datatype but... it seem to not working... :?

===================================
g_txtImportFilename := 'D:\Employee.csv';
g_filCatalogImportFile.TEXTMODE(TRUE);
g_filCatalogImportFile.OPEN(g_txtImportFilename);
g_filCatalogImportFile.READ(g_txtProcessingLine);
===================================

Comments

  • kinekine Member Posts: 12,562
    If you want to read it through code, you can use binary mode to read the data char by char and join the chars into text and split the text as soon as possible into separate fields. Than you can read long line as you wish (there is just one limit -that one field in the line is not longer than 1024 chars).
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • gisongison Member Posts: 128
    Hi Kine,
    I'm appreciate your suggestion.
    :?
  • SavatageSavatage Member Posts: 7,142
    So you're trying to import the entire csv line into one variable then break it up? there are easier ways of accomplishing this.

    You want to use a codeunit or dataport?
  • gisongison Member Posts: 128
    Hi Savatage,

    Actually, I used codeunit to import the file.
    It's done now. O:)
  • GregorDGregorD Member Posts: 26
    Hi,

    can someone please post a code sample? I have a similar problem...

    Best Regards,

    Gregor
  • einsTeIn.NETeinsTeIn.NET Member Posts: 1,050
    Take a look at the online help of NAV, function READ of DataType File:
    Remarks

    If TEXTMODE Function (FILE) is set to true, a line of text from the file is read, evaluated, and the variable is set equal to the result.

    If TEXTMODE is set to false, the number of bytes to read is determined by the size of the variable.
    "Money is likewise the greatest chance and the greatest scourge of mankind."
  • jordi79jordi79 Member Posts: 273
    I have a problem with reading from a file with a total length more than 1024 chars.

    I have created a file with 5 lines. Each line has a text with length of 500.

    The the code below is ran:
    f.TEXTMODE := FALSE;
    f.OPEN('C:\test.txt');
    f.READ(InStr);
    

    Note that InStr is a text variable with 1024 length.

    The following error occurs:

    Microsoft Dynamics NAV
    The text 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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a shorter length, like 80 chars, and I still get the error.

    Is there something wrong with the way this is coded?
  • jordi79jordi79 Member Posts: 273
    hi,
    I found my solution in --> viewtopic.php?f=23&t=29313&p=146950#p146950

    using BigText is so much simpler.
Sign In or Register to comment.