I'm creating a report to select records in a table where a string field matches a certain pattern.
The records that I need are displayed in a grid, so I can see that there are around 50 records that should be getting selected. The query to get the records from Access uses WHERE Product_Description_Short LIKE '[a-z][0-9][a-z][a-e]'
When I then try to put this into a Crystal selection formula, no records are returned.
"{Product_Costs.Product_Description_Short} LIKE '[a-z][0-9][a-z][a-e]'"
How do I need to adapt the selection formula to allow me to select the same records as in the SQL query?
Removing the selection formula completely shows all records from the table, so it's definitely the query going wrong.
Crystal Reports does not support regex, but you can use some string functions to achieve what you want.
Also there was a similar question with a link to a regex-library:
Crystal reports: is there a way to regex in crystal reports?
The following formulas use some of the basic string functions of Crystal Reports:
Example 1:
This formula works with character ranges. The problem here is that also other characters are included (for example umlauts like ä ö ü).
If this is not what you want then "Example 2" should work.
stringVar productDesc := "a3xZ";
Len(productDesc)=4 And
Left(productDesc,1) In "a" To "z" And
Mid(productDesc,2,1) In "0" To "9" And
Mid(productDesc,3,1) In "a" To "z" And
Right(productDesc,1) In "a" To "z"
Example 2:
This formula works with ASCII-codes and thus can exclude umlaut-characters.
ASCII-codes
48 to 57 are numbers [0-9]
65 to 90 are upper case characters [A-Z]
97 to 122 are lower case characters [a-z]
stringVar productDesc := "a3xZ";
Len(productDesc)=4 And
Asc(Left(productDesc,1)) In [97 To 122, 65 To 90] And
Asc(Mid(productDesc,2,1)) In 48 To 57 And
Asc(Mid(productDesc,3,1)) In [97 To 122, 65 To 90] And
Asc(Right(productDesc,1)) In [97 To 122, 65 To 90]
So with the second example, the selection formula would look like this:
Len({Product_Costs.Product_Description_Short})=4 And
Asc(Left({Product_Costs.Product_Description_Short},1)) In [97 To 122, 65 To 90] And
Asc(Mid({Product_Costs.Product_Description_Short},2,1)) In [97 To 122, 65 To 90] And
Asc(Mid({Product_Costs.Product_Description_Short},3,1)) In 48 To 57 And
Asc(Right({Product_Costs.Product_Description_Short},1)) In [97 To 122, 65 To 90]
Related
I need to be able to add .0 to integer numbers in access query. Please see example below
Current Table
61
61.5
68.0
70
72.5
84
What I would like the table to look like
61.0
61.5
68.0
70.0
72.5
84.0
The format of the field is text and would have to stay that way unfortunately due to a submission procedure we have to follow.
Any ideas are greatly appreciated.
You talk of a query but you do not mention much detail about it.
As long as the column you are formating is a numeric data type only, then you can use:
SELECT Format([columnName], "0.0") FROM tableName);
I have a CSV file with "|" delimeter but it has a bug and I want to correct it as a Hot Fix, before to get in the code, as it contains a lot of lines is hard to do it manually.
CSV example:
Michael|Cort
| 23
George|Dieter
| 25
As you can see the age is displayed in new line, but I want to remove it and put it like this:
Michael|Cort| 23
George|Dieter| 25
i used regex search with ^\|
Is this possible? if so, how could let notepad++ remove or backspace to append it to the previous line?
Thanks
Ctrl+H
Find what: \R(\|)
Replace with: $1
check Wrap around
check Regular expression
Replace all
Explanation:
\R : any kind of linebreak (ie. \r, \n, \r\n)
(\|) : group 1, a pipe character
Replacement:
$1 : content of group 1 (i.e. pipe)
Result for given example:
Michael|Cort| 23
George|Dieter| 25
I have a ms access table which has a column named description which contains several records, There is a Space in the records which are of longer lengths, I need to remove the space which is in 26th character. As i am new to access i find difficult to write queries, Any help would be greatly appreciated.
For Example descrption column has few values like this : MOXIFLOXACIN HYDROCHLORDI E/SODIUM CHLORIDE, There is a space between I and E, SO i need to concatenate it like this for all the records
MOXIFLOXACIN HYDROCHLORDIE/SODIUM CHLORIDE
Removing characters can be a difficult concept.
If you want to remove the 26th character, you essentially should take all characters except the 26th character, which is the 25 characters to the left, and all characters higher than 27 to the right.
I'm checking inline if the string is longer than 26 characters, you might also decide to check that in a WHERE clause.
UPDATE myTable
Set MyColumn = Left(MyColumn, 25) & IIF(Len(MyColumn) > 26, Right(MyColumn, Len(MyColumn) - 26), "")
The csv file contains more than one table, it might look like this:
"Table 1"
,
"id","visits","downloads","emailsent"
1, 4324, 23, 2
2, 664, 42, 1
3, 73, 44, 0
4, 914, 8, 0
...
"Table 2"
,
"id_of_2nd_tab","visits_of_2nd_tab","downloads_of_2nd_tab"
1, 524, 3
2, 564, 52
3, 63, 84
4, 814, 8
...
What is the best way to import those tables into Talend ?
Generally, that kind of multi-record format CSV format is more complex to parse.
Question : Are there are a finite number of tables?
Question: Does each table have a fixed number and order of columns?
Question: What is the separator between "tables" within the CSV?
I believe you need to take a multi-pass approach. You could do something like this.
Pass #1 - Use tFileInputDelimited
Use row separator such as "Table", No field separator, Grab 1 big field
Alternatively, you could split the first file into separate files at this stage.
Pass #2 - Split Row (on results from pass #1) on the Row Separator "\r\n" etc
Split it into multiple rows but of a single column.
Pass #3 - Extract Delimited Fields (on results from pass #2)
Extract based on a field separator
Recognize a "Table" row
Recognize a "Header row
Additional handling per Table / set of fields in header
Use the a tFileInputExcel component to read each worksheet. Then you can use tMap to join the worksheets into a target column layout assuming you want do some processing on a joined set of columns.
In a mysql table i have column whit this info..
Col.
tr10
tr210
zbr10
00010
10010
tr 10
The question is simple, i need to find in a mysql query all the records number 10.. but as you can see in the example not 10010 etc..
Result:
tr10
zbr10
00010
tr 10
I know is a mess but the records had to be load in that form..
so you have characters at the begining, in some cases spaces, or zeros..
An option could be extract (by hand) hundred of characters to another column to keep the things less complex, but at the same time i still having problems with the 000010 values..
Use regular expressions
select * from table where col regexp '^[a-z]+10$'
Play with the regex until you get your desired results, i didnt fully understand you criteria so I just made one up but the one in my example will pull all the rows with any alpha characters proceeded by 10