473,387 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

comparing 2 strings of Texts

Hi all, totally new here, treat me as a retard when I say something stupid, and thanks for your help in advance.

I have two columns of texts. 1 column contains category, such as apple, orange, banana, etc. Another column contains raw data but part of it has the category name, such as apple11111, orange is good, banana1212 soso, etc.

I have 1000 thousand raw data, 25 categories.

I would like to categorize all the raw data into the 25 categories. In another words, for all the raw data that contains the text "apple", it would be categorizes as "apple".

I don't necessarily need VBA to do the above if a simple excel function could do the same.

Thanks a lot.
Jun 5 '08 #1
1 1459
kadghar
1,295 Expert 1GB
Hi all, totally new here, treat me as a retard when I say something stupid, and thanks for your help in advance.

I have two columns of texts. 1 column contains category, such as apple, orange, banana, etc. Another column contains raw data but part of it has the category name, such as apple11111, orange is good, banana1212 soso, etc.

I have 1000 thousand raw data, 25 categories.

I would like to categorize all the raw data into the 25 categories. In another words, for all the raw data that contains the text "apple", it would be categorizes as "apple".

I don't necessarily need VBA to do the above if a simple excel function could do the same.

Thanks a lot.
hmm, i'd say INSTR will help you

lets say you've read the raw data into a string array, and your 3 categories are apple, orange and banana

then something like this will do (assume Arr1 has the raw data)

Expand|Select|Wrap|Line Numbers
  1. dim i as long, j as integer
  2. dim CatArr(1 to 3) as string
  3. catarr(1) = "apple"
  4. catarr(2) = "orange"
  5. catarr(3) = "banana"
  6. for j = 1 to 3
  7. for i = lbound(arr1) to ubound(arr1)
  8.     if instr(Arr1(i), catarr(j)) <> 0 then
  9.         'your code to store the category
  10.     end if
  11. next
Also consider using UCASE or LCASE to avoid problems with upper/lower case.

For huge amounts of data in excel check this thread (specially my very smart and useful answer ^.^)



HTH
Jun 5 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: beliavsky | last post by:
By mistake I coded something like print ("1" > 1) and got the result "True". Comparing an integer and a string seems meaningless to me, and I would prefer to have an exception thrown. Can...
5
by: Curtis Gilchrist | last post by:
I am required to read in records from a file and store them in descending order by an customer number, which is a c-style string of length 5. I am storing these records in a linked list. My...
4
by: agent349 | last post by:
First off, I know arrays can't be compared directly (ie: if (arrary1 == array2)). However, I've been trying to compare two arrays using pointers with no success. Basically, I want to take three...
88
by: William Krick | last post by:
I'm currently evaluating two implementations of a case insensitive string comparison function to replace the non-ANSI stricmp(). Both of the implementations below seem to work fine but I'm...
2
by: bobbymusic | last post by:
Hey all, my problem is when I start to compare two texts with different lenght. The point is that the texts are loaded in two RTB and I don't know how to compare them. I found that I have to parse...
2
by: Pugi! | last post by:
hi, I am using this code for checking wether a value (form input) is an integer and wether it is smaller than a given maximum and greater then a given minimum value: function...
9
by: Sonnich | last post by:
Hi! I want to have a number of strings in another file, which I can include everywhere... but I cannot make them reachable from the top file. I have looked at var and global to to this but...
9
by: | last post by:
I am interested in scanning web pages for content of interest, and then auto-classifying that content. I have tables of metadata that I can use for the classification, e.g. : "John P. Jones" "Jane...
2
by: bearophileHUGS | last post by:
Helmut Jarausch: Asking in comp.compression is a good starting point. My suggestions (sorry if they look a bit unsorted): it depends on what language you want to use, how much you want to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.