[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 185
  • Last Modified:

EXTRACTING / PARSING DATA OUT OF A TEXT OR CSV FILE

Hi Experts

We receive somewhere between 200 and 1000 text messages everyday from GSM modems located all over the country (South Africa). These messages are captured into an SMS management program which allows the exporting of these messages into Microsoft Excel format.

The SMS messages that are received all have the same format except for the length of the currency value:

FldFrom --> +27823807449
FldTo --> always blank
FldDateTime  --> 13.11.2004 16:49
FldDescription --> irrelevant information
FldText --> &KGWT: 1734350,0,0,0□□□□OK  

The "□" symbol in the FldText field represents the ENTER key. i.e the messages are  displayed as follows:

&KGWT: 1734350,0,0,0



OK

- - - - - - - - - - -
A sample of this .xls file can be downloaded from: http://www.kobweb.co.za/dev/txtautomation.xls
- - - - - - - - - -

We need to import these text messages into an Access database. However we need to filter this data and only import the following data in the following format:

MessageNumber                      (Autonumber generated by access)
MobileNumber: 27823807449    (without the preceeding + sign)
MessageDate:  13/11/2004       (Short Date format - dd/mm/yyyy)
MessageData:  17,343.50         (currency value with 2 decimal places - value will always be .00 or .50)

- - - - - - - - - - -
To parse/extract the MobileNumber was simple (we merely used =Right([FldFrom],11)
To parse/extract the MessageDate was simple (we merely set the Format of the field to dd/mm/yyyy)

However, we cannot seem to parse out only the MessageData currency value - 17,343.50.
* In everycase the currency value starts 7 characters from the left
* In everycase the FldText end with 6 characters of useless info

All we need is a way to parse/extract out only the characters starting at character number 7 and ending 6 characters from the end of the field.

We have tried all different versions of Left, Right and Mid, but cannot find a solution.

Anyone offering a quick and easy method that will allow us to import only the relevant data we need (in the correct formats) will be awarded top points.

Thx Experts!

StanKobrin


0
StanKobrin
Asked:
StanKobrin
1 Solution
 
RichardCorrieCommented:
try

Amount=cdbl(mid(FldText,7,instr(7,FldText,",")-6))/100
0
 
StanKobrinAuthor Commented:
Hi Richard

That worked absolutely perfectly. All I did was then convert the field to Currency and i'm up and running.

Points well deserved.

Stan
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now