Options

Removing " and ' from a string before dataport export?

Matt.HillMatt.Hill Member Posts: 32
Hi all

I need to be able to export the entire list of items from our inventory list as a CSV file so they can be used on an external distributor's system.


I've written a dataport that does just this and works fine, except for when the item's description contains any of the following characters: ' " or ,

The items description needs to be split across two fields as our descriptions are longer than their system can handle.


I've tried using ' DELCHR' but it says that the second parameter (the character I am trying to delete) is invalid!


So then I tried re-writing the dataport as a report, as I know I've achieve exporting item descriptions by enclosing the description in single quotes, e.g.
ExportFile.WRITE("No." + 
                     ',"' + Description + '")

However, when I try (remember the description needs to be split):
ExportFile.WRITE("No." + 
                     ',"' + Desc1 + 
                     ',"' + Desc2 + '");

I get the same 'errored' output file as I got with the dataport.


Does anyone know how I can get round this?

Thanks.
[/code]

Comments

  • krikikriki Member, Moderator Posts: 9,120
    Description := DELCHR(Description,'=','"');
    

    Or try TAB-seperated in the other system can read it.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • kinekine Member Posts: 12,562
    you must use:
       ''',"'
    

    ( ' is doubled in the string)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Miklos_HollenderMiklos_Hollender Member Posts: 1,598
    You can create Text Constants for ', " and the others and use DELCHR with them. Or a Char variable if you like it more explicit: DoubleQuoteChar := 34 and DELCHR(text, '=', FORMAT(DoubleQuoteChar));
Sign In or Register to comment.