Bob Schneider
asked on
Parsing a String Using VB6 & FSO
Trident-Data-String-Identification-.docx I'm looking for a way to parse the data in the attachment as comma-delimited based on the color coding indicated. The data would come as a plain text file and need to be parsed and saved as a plain text file. This would be done using a vb6 application using the file system object. Ideas? Note that the strings are fixed length.
No attachment.
why use vb6 when you can use powershell
000014de3eed
BS
March 3, 2017 12:38:43 AM
$testdata = "aaE1000014de3eed00311703031238431300BS"
$TagID = $testdata.Substring(4,12)
$strDate = $testdata.Substring(20,14)
$data = $testdata.Substring(36,2)
$TagID
$data
$mydate =[datetime]::ParseExact($strDate,'yyMMddhhmmssff',$null)
$mydate
000014de3eed
BS
March 3, 2017 12:38:43 AM
It looks like your attachment is a Word document but I couldn't open it. Are you doing this in Word or was your attachment your attempt at uploading the non-Word file that you need parsed?
ASKER
David, I use a race timing app that I wrote in vb6. I need to pull the data that comes from the timing software in a text file that is formatted like the word doc I posted (Martin, I will convert it to pdf and re-attach) and parse it differently so my program can process it for race results.
Trident-Data-String-Identification-2.pdf
Trident-Data-String-Identification-2.pdf
Can you just attach the text file?
ASKER
Sure. Here it is.
trident_data.log
trident_data.log
ASKER
Here is a sample of what I want to convert it to. Note that not all of the fields in the original file are needed in the destination file. Just looking for a way to break it up based on the color code indicated initially.
192.168.1.101.txt
192.168.1.101.txt
Using the second line in your pdf as a template
aaE1000014de3eed0031170303 1238443600 LS
please show what the comma-delimited output line should look like. I ask because I'm having trouble reconciling what you show in your 192.168.1.101.txt file (like the "3" in the first row) with what you show int he pdf. I know that the data itself is not the same.
aaE1000014de3eed0031170303
please show what the comma-delimited output line should look like. I ask because I'm having trouble reconciling what you show in your 192.168.1.101.txt file (like the "3" in the first row) with what you show int he pdf. I know that the data itself is not the same.
ASKER
Actually if you could simply show me the most efficient way to do the following in the non-comma file, I would be much indebted...I will often have to do this repeatedly for up to 10,000 lines or more during the course of a race:
Consider this string: aaE1000014de3eed0031170303 1238431300 BS
-Remove the first three characters.
-Remove the last two characters.
-Begin building a new string with 1, (the "1" is the 4th character in the old string)
-Remove characters "000014"
-Append the next six characters and a 0 and commas as follows (showing the entire new string): 1, de3eed, 0,
-Remove characters "0031170303"
-Append the next six characters with colons inserted as follows: 1, de3eed,0,"12:38:43
-Convert the next four digits as a fraction from hex to decimal and append...in decimal form .1300 is .0742...along with a close quote so the new string is now
1,de3eed,0,"12:38:43.0742"
That is what I need. I could piece it together but I am concerned that it would not be the most efficient process so I would like to run it by the experts given the volume of times I would need to do this.
Thanks so much.
Consider this string: aaE1000014de3eed0031170303
-Remove the first three characters.
-Remove the last two characters.
-Begin building a new string with 1, (the "1" is the 4th character in the old string)
-Remove characters "000014"
-Append the next six characters and a 0 and commas as follows (showing the entire new string): 1, de3eed, 0,
-Remove characters "0031170303"
-Append the next six characters with colons inserted as follows: 1, de3eed,0,"12:38:43
-Convert the next four digits as a fraction from hex to decimal and append...in decimal form .1300 is .0742...along with a close quote so the new string is now
1,de3eed,0,"12:38:43.0742"
That is what I need. I could piece it together but I am concerned that it would not be the most efficient process so I would like to run it by the experts given the volume of times I would need to do this.
Thanks so much.
Now you are asking a completely different question
where does column 1, 3,4,5 come from
your date/time data seems to contain Hex digits in the supplied data
where does column 1, 3,4,5 come from
your date/time data seems to contain Hex digits in the supplied data
ASKER
No, I am asking the same thing I have asked from the beginning...and that is how to take a string of characters in a text file and re-format it into another string of characters based on order and significance in each. I will close the question. I do appreciate your effort.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you very much!
ASKER
Martin, your script worked like a charm. I can't thank you enough!!! I just need one more thing. I need to convert the tag number to decimal from hex. It would be the "de3eed" from my instructions above. Is this a quick fix in your script or should I post another question?
ASKER
Never mind Martin. I was able to do that. Thanks so much!
You’re welcome and I’m glad I was able to help.
If you expand the “Full Biography” section of my profile you’ll find links to some articles I’ve written that may interest you.
Marty - Microsoft MVP 2009 to 2017
Experts Exchange Most Valuable Expert (MVE) 2015, 2017
Experts Exchange Top Expert Visual Basic Classic 2012 to 2018
Experts Exchange Top Expert VBA 2018
If you expand the “Full Biography” section of my profile you’ll find links to some articles I’ve written that may interest you.
Marty - Microsoft MVP 2009 to 2017
Experts Exchange Most Valuable Expert (MVE) 2015, 2017
Experts Exchange Top Expert Visual Basic Classic 2012 to 2018
Experts Exchange Top Expert VBA 2018