home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / database / 7710 < prev    next >
Encoding:
Text File  |  1992-11-08  |  2.4 KB  |  64 lines

  1. Newsgroups: comp.databases
  2. Path: sparky!uunet!munnari.oz.au!comp.vuw.ac.nz!ferrari.datamark.co.nz!david
  3. From: david@datamark.co.nz (David Rowland)
  4. Subject: Re: HELP: Loading text file to FoxPro database
  5. Message-ID: <1992Nov9.023732.29172@datamark.co.nz>
  6. Date: Mon, 9 Nov 1992 02:37:32 GMT
  7. References: <50990003@hpsgm2.sgp.hp.com>
  8. Organization: Datamark International Ltd.
  9. Lines: 53
  10.  
  11. In article <50990003@hpsgm2.sgp.hp.com> thwaites@hpsgm2.sgp.hp.com (Damien THWAITES) writes:
  12. >
  13. >I have an ASCII text file that contains one field from a database per line.
  14. >As there are 20 fields in each record, there are 20 lines in the file for
  15. >each record. I want to load this text file into a FoxPro database with
  16. >the same number of fields (20) per record.
  17. >
  18. >How can I read this text file into a FoxPro database ? I tried using the
  19. >APPEND FROM command but FoxPro loaded each line of the text file as a
  20. >separate record. I need FoxPro to place each of the 20 lines into the
  21. >corresponding database record field. Any pointers are much appreciated !!
  22. >
  23. One of the easiest ways to change ascii files, believe it or not, is
  24. by using Qbasic which comes with MS-DOS 5.  This package is not used
  25. to its full potential by alot of programmers which is a shame.  Once I
  26. got use to it, I was using this package to format files etc alot
  27. faster then appending them to a database and using foxpro or clipper.
  28.  
  29. An example program would be as follows:
  30.  
  31. OPEN <old file> FOR INPUT AS #1
  32. OPEN <new file> FOR OUTPUT AS #2
  33.  
  34. :LOOP
  35.     A$=""
  36.     FOR N=1 TO 20
  37.         INPUT #1, B$
  38.         A$=A$+B$
  39.     NEXT
  40.     PRINT #2, A$
  41.     IF NOT EOF(1) THEN GO TO LOOP
  42.  
  43. CLOSE #1, #2
  44.  
  45. NOTE: I Dont have Qbasic available and wrote the above program from
  46. memory.  It might have to be changed a bit but this should be easy.
  47. The end result would be a new file with one line per record.
  48.  
  49. I have also been asked a similar question to this one before and
  50. discovered the file in question was infact a RTF file.  If this is the
  51. case, a simple APPEND FROM <file> TYPE RTF will do the trick.
  52. Likewise, try to discover the format for the ascii file and see if
  53. foxpro can append from that format.
  54.  
  55. Good Luck.
  56.  
  57.  
  58.  
  59. -- 
  60. | David Rowland       | The British are using New Zealanders.  They must |
  61. | Datamark Intl Ltd   | really mean business !                           |
  62. | Wellington          |      -  General Rommel During Northern African   |
  63. | NEW ZEALAND         |         Campaign WWII.                           |
  64.