Jump to content


Click the link below to see the new game I'm developing!


Joseph Bove

Member Since 07 Jul 2000
Offline Last Active Nov 21 2018 04:24 PM
-----

#11094 take on data from excel file

Posted by Joseph Bove on 19 January 2005 - 04:00 PM

Along the lines of what Bill is saying:

Here is a global logic that makes dealing with csv files much nicer

PARSE

A PARMS($$STRING, $DELIMITER)
   
   #DELIMIT = INDEX($$STRING, $DELIMITER)
   IF #DELIMIT = 0 THEN
      $$STRING = ''
      $$PARSED_STRING = ''
      STEP 1
   ENDIF
   $$PARSED_STRING = $$STRING(1, #DELIMIT - 1)
   $$STRING = $$STRING(#DELIMIT + LEN($DELIMITER), LEN($$STRING))
   STEP 1

1  RETURN($$PARSED_STRING)

PARSE is destructive. Assuming that your file looks like "name", "address 1", "address 2"

You could simply code as follows
$NAME = PARSE($$ASCII_TEXT, ',')
$$ADDRESS1 = PARSE($$ASCII_TEXT, ',')
$$ADDRESS2 = PARSE($$ASCII_TEXT, ',')
We also have a separate global logic REPLACE for character substitution

So, to finish the job,
REPLACE($NAME, '"','')
REPLACE($$ADDRESS1, '"', '')
REPLACE($$ADDRESS2, '"', '')
hth,

Joseph


Click the link below to see the new game I'm developing!