Need to export data into a file using put unformatted

Sowmya11

New Member
Hi,

We need to export data from QAD to output file.
In output file, we need to extract the data in following format,
1. Data must be exported without single quotes.
2. Labels must be in first line, first record must be in 2nd line, second record must be in 3rd line, etc(in notepad file).
3. File must be in csv format.
1st steps can be achieve by following command.
Put unformatted “Item name” delimiter
“Item description” delimiter
“item type” skip.
Put unformatted pt_part delimiter
Pt_desc delimiter
Pt_type skip.

When we use this command all the records come in one single line (cannot achieve the 2nd step)(skip is working fine in Excel but not in notepad file)
Please suggest how can we make it work in excel as well.
 

RealHeavyDude

Well-Known Member
SKIP is platform dependent. Are you creating the report on a *nix platfom?

*nix use only LF (line feed) which is decimal character 10.
Windoze needs CR (carriage return) + LF which is decimal character 13 + 10.

You can find more details here ( http://en.wikipedia.org/wiki/Newline )

Running your code on *nix only produces LF whereas Excel needs CR + LF. Either you change your code to explicitely put chr(13) and chr(10) or you use a utility like unix2dos to convert the file.

Heavy Regards, RealHeavyDude.
 

TomBascom

Curmudgeon
Your requirement regarding "1. Data must be exported without single quotes." is very strange. What do you do if a character field has an embedded comma?

In any event -- your code should look something like this:

Code:
output to "outfile.txt".
put unformatted "label1 " "label2 " "label 3" skip.
for each tableName no-lock:
  put unformatted field1 "," field2 "," field3 skip.
  /* export delimiter "," tableName. */   /* this would work really simply except you appear to not want to have quotes around character values... */
end.
output close.
 
Top