Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compare text string to 1st value of .csv file & return 2nd value

Status
Not open for further replies.

Jacque

Technical User
Nov 9, 2001
301
US
[red]CRv9, DB2, WinXp[/red]

I'm trying to create a formula which will compare a text string to the first text string (value before the comma) of a .csv file and return the correct text string (value following the comma). Below is what I came up with (unfortunately I'm not experienced with loops) and while this does return the correct text string it isn't working the way I need it to and it's slow. [cry]

Here are the contents of the csv file and the formula.

The file {test_csv.French} contains the following:

Yes,Oui
No,Non
Alt ID,Autre ID

The formula @Translation contains the following:
whileprintingrecords;
stringVar vText := "Alt ID";

stringvar array times:={test_csv.French};
numbervar loops:=ubound(times);
numbervar a;
stringvar vOutPut;

for a:= 1 to loops do
(
if vText = split({test_csv.French},",")[1] then vOutPut := split({test_csv.French},",")[2],
a:=loops;

if vOutPut = "" then vText else
vOutPut;
);

vOutPut

This is what it's doing in the report:

record1 @Translation is blank
record2 @Translation is blank
record3 @Translation = Autre ID
record4 @Translation = Autre ID
record5, 6, 7..... @Translation = Autre ID


What am I doing wrong and how can I fix it? I also hope to use it for strings returned from the db as well. I was wondering about having a UFL created instead to do the comparison, return the text string and to improve the processing time.
Thanks, [cheers]
Jacque
 
I don't think that you want a loop.

Set up the CSV file as a datasource using ODBC, then in the Report->Edit Selection Formula place:

{table.Field1} = "Alt ID"

Note that you will end up with different table.field values.

I would opt for using a parameter to identify the string to be found.

This way Crystal will scan the CSV file for only those rows and return them.

-k
 
Hi -k,
When I added the csv file, I tried linking it to my existing DB2 tables as an != (not equal to) join because there really is nothing to link to and I get an error message: More than one database driver has been used in this report. If you want to change the database drivers use Database/Set Location. Also, please make sure that no SQL Expression is added and no server-side group-by is performed.. I also tried not linking it and I got the same error message. I'm trying to use the csv file to translate/replace the original text strings with their translations/replacements. I need it to be used for every text string displayed on my report whether the text is returned from the db or a column header. I was hoping to create a custom function or a UFL to handle this. I know there are a few International UFLs available but they are cost prohibitive for our use.
Thanks,
Jacque
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top