Click here to Skip to main content
15,892,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have sentence having csv values from table like 'PROVIDENT FUND,Employee Contribution to PF,PF,Employee PF ' .Now I want to match exact word '
HTML
Employee Contribution to PF

' exist in this sentence or not without splitting and mapping each values .Because this sentence may increases .And with Splitting and mapping may decrease performance .So how to match exact word in simple way ?

What I have tried:

I get string values in loop after splitting then I mapped.For this I made two for loops in which outer loop gets every row csv values rows and then loop on csv field after splitting.Now i want proper solution for this without for loop as performance decreases as values increases in both inner and outer loop values.
How to resolve this?Thanks in advance ......
Posted
Updated 25-Jul-16 8:45am

To be honest, I'd use an existing CSV reader: A Fast CSV Reader[^] is good.
You can then just use string.Contains to find your matches.
 
Share this answer
 
Quote:
Because this sentence may increases .And with Splitting and mapping may decrease performance
Do you write this because you know another way that perform better ? if so, program it.

- Simple minded method: Take the sentence and search a given word using standard function. Search "fund" in "I have made a crowdfunding.", you will have a match, but is it what you want ? You need to check for spaces before and after the word unless it is the first or last one. Is it still the easy way.

- split method: you split the sentence in words only once. Each list entry is a word, you just have to check if a list entry is equal to a word or not, no special cases.

Use the split method. when you think of a better method, try it and compare the performance results. and tell us.
 
Share this answer
 
Comments
sp_suresh 8-Aug-16 7:04am    
Thanks , I already set this solution by split method with much better performance from database level ....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900