data 5 sets

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
alsm
Posts: 1
Joined: 01 Jul 2013 09:19

data 5 sets

#1 Post by alsm » 01 Jul 2013 09:22

No one at computing.net could do this claiming it's impossible so i decided to post here:
The problem is as follows:
We have 5 different sets of data which we'll name in the following order:
car:location:land:beach:table.
Now the problem is, all of that data is in 1 line in a .txt file, which will be like this:
mercedes:newyork:big:somebeach:small,car1:newjersey:small:anotherbeach:big,etc,etc,etc..
You get the point, each set of data will be separated by a comma, now the problem is, i want it to be filtered as follows:if location exists, ignore land and beach and just export the data:car:location:table. The other problem is, some may not contain land and beach and therefore will be in the following format if those two don't exist car:location:::table, now sometimes location will not exist where then, land and beach will so it will be in the following format:car::land:beach:table. Sometimes, location and beach and land will all exist and be in the format car:location:land:beach:table. In short, the logic to be used is:
if location doesn't exist, export car:land:beach:table to data.txt,
if beach and land don't exist, export:car:location:table,
if location exists and beach and land exists, export the following data:car:location:table.
Many thanks to the person who can achieve this in either vbscript or batch.
The data is not necessarily in one line, i'd like it to be able to grab the data from a .txt file.
Here's sample data:
Bob:59438dnsk4905830:::example1@,cvdxc:49djdns4ks84:::example2@,toms:dksi48593jsks49595u:::example3@,ael:4986969sndbdklsodk:5443sdsdaad343da24324:N{}<.??{}>:.dk4o204899_=_+sdk:examples_""@,John::49384893:9349DJ,SKkdsnk{{}>??>>??P$d;;s':john1345@
The desired output:
1.Bob:59438dnsk4905830:example1@
2.cvdxc:49djdns4ks84:example2@
3.toms:dksi48593jsks49595u:example3@
4.ael:4986969sndbdklsodk:examples_""@
5.John:49384893:9349DJ,SKkdsnk{{}>??>>??P$d;;s':john1345@
Sometimes, beach may contain the character : and , as well, so that makes it even harder to accomplish.

penpen
Expert
Posts: 2009
Joined: 23 Jun 2013 06:15
Location: Germany

Re: data 5 sets

#2 Post by penpen » 02 Jul 2013 16:07

You haven't fully specified your problem.
For example you need to describe, how you determine where the data in the beach field ends, as colon and comma are valid characters in there.

For instance you may have two export cases:
- first export case
1.C:Lo:La:B:T
2.c:lo:la:b:t
- second export case (the content of beach is B:T,c:lo:la:b)
1.C:Lo:La:B:T,c:lo:la:b:t

Both export cases are basing on the same data source:
C:Lo:La:B:T,c:lo:la:b:t.

The second problem is, you are contradicting yourself:
alsm wrote:Now the problem is, all of that data is in 1 line in a .txt file, which will be like this:
And later you wrote
alsm wrote:The data is not necessarily in one line, i'd like it to be able to grab the data from a .txt file.


penpen

Edited: Removed wrong Information.

Post Reply