home *** CD-ROM | disk | FTP | other *** search
/ ftp.robelle3000.ai 2014 / 2014.06.ftp.robelle3000.ai.tar / ftp.robelle3000.ai / faq / q9.txt < prev    next >
Text File  |  1995-12-13  |  2KB  |  44 lines

  1. Correct Number of Commas.
  2.  
  3. A customer received a comma-delimited file from an outside source.  He had to
  4. edit some of the fields to make sure they would not get rejected during the
  5. import operation.  He also wanted to make sure that he had the exact number of
  6. fields, no more, no less.
  7.  
  8. Let us assume that the file contains six fields and that the fields do not
  9. contain commas.  In a normal comma-delimited file, we expect each record to
  10. contain five commas.  If records contained fields with commas, however, the
  11. field count may not be accurate.
  12.  
  13.      This,line,has,exactly,six,fields.
  14.      This,line,has,more,than,six,fields.
  15.      This,line,has,only five,fields.
  16.  
  17. We need to use the Pattern option and the QeditCount JCW to make sure there
  18. are no more than five commas.
  19.  
  20.      /list "@,@,@,@,@,@,@" (pattern)
  21.      if qeditcount > 0 then
  22.         echo ***** !qeditcount lines with too many commas *****
  23.      endif
  24.  
  25. Similarly, we can use the following commands to make sure the records have at
  26. least five commas.  Notice that we are also using the Nomatch option on the
  27. List command.
  28.  
  29.      /list "@,@,@,@,@,@" (pattern nomatch)
  30.      if qeditcount > 0 then
  31.         echo ***** !qeditcount line(s) with too few commas *****
  32.      endif
  33.  
  34. You might want to put all these commands into a single command file and call
  35. it Chkcomma.  Running Chkcomma from Qedit would give us the following results:
  36.  
  37.      /chkcomma
  38.          2     This,line,has,more,than,six,fields.
  39.      1 line found
  40.      ***** 1 line(s) with too many commas *****
  41.          3     This,line,has,only five,fields.
  42.      1 line found
  43.      ***** 1 line(s) with too few commas *****
  44.