473,385 Members | 1,901 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,385 software developers and data experts.

Separate out information that has been typed into one field?

283 100+
I imported some data from an excel spreadsheet to a table in Access. There is one field where they have two pieces of information typed into one column that i want broken in to two columns. Is it possible to write a code or validation rule to automatically seperate the information with out having to go back and do it by hand?

for example;

Column 1
[Name 1 Frank] (info)

I want to break this in to two columns

[Colm 1]......[Colm 2]
[Name 1]....[Frank]

Just wondering if it can be done because going back and entering in a thousand of these by hand is really time consuming.
Mar 10 '10 #1
18 1975
TheSmileyCoder
2,322 Expert Mod 2GB
Would depend on the date. You can do alot of seperating if you can find a valid criteria for the whole dataset. Try to supply us with some real test data, and we can look at it.

The easiest is if there is any delimiter used between the 2 data types, then you can use Split.
Mar 10 '10 #2
NeoPa
32,556 Expert Mod 16PB
As Smiley says, you need to have a clear understanding of what criteria to use to determine where the split should occur. Is it on a number of characters? Is it on a separator character?

Your example data wouldn't be obvious as the spaces between your fields are not the only spaces. It would split it [Colm],[1],[Colm],[2], etc.
Mar 10 '10 #3
slenish
283 100+
I do have a clearn understanding of where to split. First part starts with Box and then a number like (Box 1) then after that is a name like Jeff.

The word Box always stays the same but the number next to box changes and goes up by one each time. Also the name next to box could be the same for so many records and then change. so there is a good dividing point.

There are no dates next to the records only thing I can see that stays constant is an account number. So maybe I could make it pull account number 5 column Shipper then split box 1 from name Jeff....

What do you think??
Mar 10 '10 #4
NeoPa
32,556 Expert Mod 16PB
If that's your clear understanding then we have a problem. It doesn't match your example data. For us then, it is far from clear. I would hesitate to proceed on this basis.

Your third paragraph makes no sense to me at all. In the context of the example data provided I see nothing that remotely matches what you say.

This may simply be the example data is poorly chosen, but to proceed it is important that what you say matches the data so that we can get a clear understanding (if we're to be of any reliable help).
Mar 10 '10 #5
topher23
234 Expert 100+
This is a classic exercise in string manipulation. Since you're splitting a string in half, you're going to need to use at least 3 string functions: Left, Right and InStrRev (or InStr). Look up the functions in Access help to get an idea of how they work. You'll end up with two statements: one that gives you 'Box 1' and one that gives you 'Jeff'

If "Box 1 Jeff" as in your example is the ONLY thing in this field, your expressions will end up looking something like
Expand|Select|Wrap|Line Numbers
  1. Left([FieldName],InStrRev([FieldName]," ")-1)
  2. Right([FieldName],InStrRev([FieldName]," ")-2)
where [FieldName] is your actual field. In the case of "Box 1 Jeff", the first expression produces "Box 1" and the second expression produces "Jeff"

Hope this is helpful!
Mar 10 '10 #6
slenish
283 100+
Nice example topher23.

The only question I have now is where would I put that code? Im not using a form im just directly taking a downloaded excel file and importing it in to a table so would i put that as a validation rule??


NeoPa,
My appologies on the third paragraph Im not sure what i started writing there. I should have just left the third para out. Didnt really need it.

I have another problem that im trying to deal with that is more urgent than this. I am trying to create an if statement for a number box on my form. What I want to do is make it so you have to enter in at least 5 numbers in to the box no more no less. I have it half working where if you enter in more than 5 you get an error message but less than 5 does nothing. Here is what i have so far.
Expand|Select|Wrap|Line Numbers
  1. Dim number, zipCode As Integer
  2. Dim error As String
  3.  
  4. #Const number = 0
  5. zipCode = 5
  6.  
  7. If number < zipCode 
  8. error = " Not enough numbers. \n"
  9.  
  10. ElseIf number > zipCode Then
  11. error = " To many numbers in field. \n"
  12. End If
  13. 'End If
Mar 11 '10 #7
NeoPa
32,556 Expert Mod 16PB
@topher23
In fact Smiley has already suggested a solution that uses only the one function (Split()) which is perfectly viable.

What we are simply waiting for now is a clear and consistent definition of what determines the split. None of these solutions works well if the count of the characters is what's used to split the data.
Mar 11 '10 #8
NeoPa
32,556 Expert Mod 16PB
@slenish
That's not a problem Slenish. However, the situation is still quite unclear due to the example not matching your explanation.
@slenish
This may not be answered here. New questions require separate threads. On the plus side, that is quite easy for you to do.
Mar 11 '10 #9
slenish
283 100+
Im guessing that it cant be done. Because there is no other way to seperate the information except for the count of characters, and that is not the best because the count can change. It does not stay constant. There could be between 11 - 13 characters.

Apperciate the help on this but it will take longer to figure this out than it will be to seperate by hand. I will just do it the old fashion way.

Also you dont have to be rude when replying to my questions!!
Mar 11 '10 #10
NeoPa
32,556 Expert Mod 16PB
@slenish
I wasn't aware I was being. If you'd like to be more specific I could consider what you're saying.

Frankly, I thought I was being quite patient considering the number of times I seemed to need to repeat the same points. Consideration would be shown by replying to points raised by someone trying to help you. I'm quite used to a much lower level of behaviour from the general public though, than I would hold myself to, so I try to show patience.

If you think that being in a position where I need to point out again that you haven't responded to my request for some information that is consistent is somehow an indication that I lack manners, then clearly there is a large gulf between our different understandings of what determines considerate or polite behaviour.

Ultimately, there is no rule that you must reply in any way when requested for information, but to fail to do so is not likely to encourage anyone to want to volunteer their spare time trying to help you. If you want to make that my fault then I'm ok with that, but it won't get you very far ultimately.
Mar 11 '10 #11
slenish
283 100+
It was not the comment of you wanting more information it was the comment of you saying

"This may not be answered here. New questions require separate threads. On the plus side, that is quite easy for you to do.

I find that rude on the basis as it comes off as you saying hey well at least you are smart enough to do this!

I tried to provide as much info as I could. Im not sure what kind of information you are looking for?? I thought I was pretty straight forward. I was going to post a screen shot but it does not look like I can. At this point it seems more trouble than its worth.

So im moving on to my other question in a new post
Mar 11 '10 #12
TheSmileyCoder
2,322 Expert Mod 2GB
Hi Sleenish

There are several quite good and easy ways to do this. The problem is for us to decide, we need "high quality" test samples. The language of programming is so specific that when we write it we need to be so as well. What NeoPA (and myself) gets frustrated about is asking the same question to the Original Poster, several times over. Sometimes we end up doing this 5 times per forum visit, and the frustration builds up, and happens to get released on the 5th poster (in this case you).

Please provide 5 records exactly as they stand in your table.

Your example for instance,
[Name 1 Frank] (info)
When I look at that, I know it would be quite easy to make the split if the square brackets [] and the () are truly there. But im unsure as to whether they are truly part of the data, or if its something you added, trying to make your example more clear.
Mar 11 '10 #13
NeoPa
32,556 Expert Mod 16PB
@slenish
In that case you can ignore my earlier comments. I can just assure you that my intention when writing that was not to sound patronising. You'd be surprised at the variety of posters we get on here. Some are so unsure of themselves, and so not at home when posting (as it all feels so foreign to them), that they really do post in the same thread because they think just starting a new thread is complicated. I don't wish to bore you with all the reasons why this makes it harder to work with for both the OP (You in this case) and the experts alike, but it's important for all the moderators (I'm also a moderator even though I'm an administrator) to ensure this is fixed when it occurs.

It's obviously easier to guess how someone will react after they've been posting a while, and easier to slip up when dealing with newer members. Let me just say that the wording there was an attempt to be friendly (as a moderator it's very easy to ruffle feathers anyway), rather than the reverse, and absolutely no offense was intended.
Mar 11 '10 #14
slenish
283 100+
Neo Pa,

Everything is cool. I appologize for taking what you were saying the wrong way. I will also work toward trying to make sure I write out my questions better and word things better so they come across clearer. I do apperciate your help in all the questions I have posted thus far. I know you have been there on a few of them and I do apperciate you taking time out or you day to be there for people such as myself. I hope we can just put this behind us and keep moving forward on a positive beat.

See you in the next post

slen

TheSmileyOne about the [] brackets I put around my example. Sorry about that they were not supposed to be part of the wording I was just trying to use those symbolize a column. Is there another way I should be doing this to make it more clear?

Thanks
Mar 13 '10 #15
TheSmileyCoder
2,322 Expert Mod 2GB
There is nothing wrong with brackets as long as you specify they are not part of the field data, they are used as delimiters.
Post a few lines of example data, but real data (if its social security numbers or something just switch out some of the numbers so its "faked" numbers, but keep the structure intact.
Column 1
[Name 1 Frank] (info)

The best way for us to determine a split, is by looking at real data. Again when I look at your example, I dont actually know whether Name is actually written in each row, or if you have replaced some parts of it. What is the (info) part for instance? is that also in column 1? Is it a very long string of stuff, or is it something simple. If you use the [code][/code] you can also make it stand nice and clear (with a little work).
If your columns have real names, it would also be a good idea to say so.

Example:
Expand|Select|Wrap|Line Numbers
  1. Column 1           Column 2
  2. Name 1 Frank       Other info
  3. Name 1 Frank       Other info
  4. Name 1 Frank       Other info
  5. Name 1 Frank       Other info
  6. Name 2 Alice       Other info
  7. Name 2 Alice       Other info
  8. Name 2 Alice       Other info
If I knew this is what the data looks like, I would simply split on the second space, take me 30 seconds to write a split function for that. Instead we have used long time now asking back and forth... :P
You could even do a screenshot of your table, and poste that. An image speaks more then a thousand words! (Unless its VBA of course :P)
Mar 13 '10 #16
NeoPa
32,556 Expert Mod 16PB
Everything cool indeed Slenish, though there's really no need to apologise. The medium that we work in is quite prone to misunderstandings (I suffered from a similar issue myself earlier as you saw). I can hardly blame you for misunderstanding me when I've already misunderstood you.

Moving on.

Smiley is clearly going through the same process that I am, looking for a reliable set of logic to implement. Neither of us has a problem implementing the logic once it's determined exactly what that is, and he, like I, feels we can make a pretty good stab of determining it for you if only we could see some live data. If you post that for us I expect some more helpful answer will be forthcoming shortly.

It's fine if you no longer wish to proceed (as stated earlier), but if you would like to then we both feel we're a simple step short of a productive result (At least if not that, we will be in a position to explain that the data doesn't lend itself to this process and human intervention would be required).
Mar 13 '10 #17
topher23
234 Expert 100+
Wow, been a while since I've been on here. NeoPa, I did see Smiley's Split method, but since there were multiple spaces as delimiters, that method was no good. This is why I suggested using InstrRev to find the last instance of a space and use that as the delimiting factor. As my post showed, that method will work if you need to split the last word of data off and only the last word.
Mar 23 '10 #18
NeoPa
32,556 Expert Mod 16PB
No worries Topher. If Slenish still requires this (which is now doubtful) we can probably catch it, but we'd need the example data first as the specification, as it stands, is too ambiguous. Most times incorrect answers come in, they are more a result of the question being unclear than a lack of understanding of the poster. There are exceptions, but usually it's in the complexity, or ambiguity, of the question. They're mostly caught one way or another too, so don't worry if sometimes you notice an answer that doesn't quite match.
Mar 23 '10 #19

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

Similar topics

31
by: Robert Brown | last post by:
Let's say I have a type hierarchy: (just an example) the general entity customer: CREATE TABLE customer(customer_id int, customer_name varchar(250), customer_type int) three specific...
2
by: Giedrius | last post by:
I would like to create a typed dataset, from which I could create such xml document using WriteXML method. Is it possible? ............ <Fields Count=34> <Field Name="name1">value1</Field>...
0
by: magister | last post by:
Hello, Can anyone please help me to understand why when I use one XSD file to create a DataSet.cs file it gives me a much longer file with more cs code which allows Typing for all my elements...
6
by: Support4John | last post by:
a2k (9.0.6926) SP-3 Jet 4.0 SP-7 I have a form with combo box field that allows the user to select from the combo box or type in the field value that may or maynot be in the combo box field. ...
3
by: EJH | last post by:
I have a Database that has three tables. One of the three is just a table that contains three fields and is filled with reference information. One field is 3-Digit(primary key), the next is...
2
by: Mark | last post by:
Just wanted to confirm that my understanding of a strongly typed language is correct: 1. .NET is a strongly typed language because each variable / field must be declared a specific type (String,...
12
by: Whoever | last post by:
Hi, I'm trying to return an XmlDocument or XmlNode converted from a typed dataset. public XmlNode whatever() { MyTypedDataSet ds = new MyTypedDataSet(); return new XmlDataDocument(ds); }
6
by: DraguVaso | last post by:
Hi, Something I don't understand about a Typed DataSet: When a value in the DataSet is DBNull, it throws this error: "Cannot get value because it is DBNull". But aren't Typed DataSets...
17
by: Gerrit | last post by:
Hallo, In my application, the user must logon with a username and a password. In all the tables in my database, there is a field user. By saving new or changed records, the username is writed to...
2
by: =?Utf-8?B?UGV0ZXI=?= | last post by:
When I'm debugging a Windows Forms Application in VS2005 IDE, how can I check whether a dataset is strongly typed or not in Watch window? Are there some properties or methods only exist for...
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
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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,...

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.