Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Importing/exporting to/from fixed text files
Message
From
28/08/2003 12:34:24
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
28/08/2003 12:07:47
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00824249
Message ID:
00824259
Views:
23
This message has been marked as the solution to the initial question of the thread.
I think that for a start, you should take a look at my article on text import/export, which shows several alternative methods.

http://www.levelextreme.com/Magazine/August2003/Page20.asp

You can also adapt my reporting class (download #9991), to generate the text. The text-report is basically created as a text file.

>Hello,
>
>I'm using TEXT...ENDTEXT command for exporting the content of a table into a fixed txt file, which must have each row, delimited by a line feed and a carriage return or a record separator. The problem is that the first line will come each time empty. What shell I do in order to avoid this and is there a better way to this beside TEXT command?

For the first line, if you use TEXTMERGE, produce the output with the "\\" command.

As to other ways, personally I prefer "?" and "??" commands.

>Another problem is that when at the end of the row I insert the record separator <> this one will add one character to the row so there would be a problem if the last field in the row should use the maximum length admitted. Either I will have the last field one character less that is supposed to be or I would exceed the maximum length of the row with one character so that will give me an invalid file.

I don't quite understand; is your text-file with fixed-length fields?

>Any ideas for importing from a fixed txt file, should I use FGETS().

LLFF like fgets() gives you maximum control, but often some of the other solutions are simpler. For instance, if you have less than 65000 lines in all cases, you can use a combination of FileToStr() and alines().
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform